Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: typec: ucsi: Fix reuse of completion structure

The role swapping completion variable is reused, so it needs
to be reinitialised every time. Otherwise it will be marked
as done after the first time it's used and completing
immediately.

Link: https://lore.kernel.org/linux-usb/20220325203959.GA19752@jackp-linux.qualcomm.com/
Fixes: 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations")
Cc: stable@vger.kernel.org
Reported-and-suggested-by: Jack Pham <quic_jackp@quicinc.com>
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20220405134824.68067-2-heikki.krogerus@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Heikki Krogerus and committed by
Greg Kroah-Hartman
e25adcca 87710394

+4
+4
drivers/usb/typec/ucsi/ucsi.c
··· 949 949 role == TYPEC_HOST)) 950 950 goto out_unlock; 951 951 952 + reinit_completion(&con->complete); 953 + 952 954 command = UCSI_SET_UOR | UCSI_CONNECTOR_NUMBER(con->num); 953 955 command |= UCSI_SET_UOR_ROLE(role); 954 956 command |= UCSI_SET_UOR_ACCEPT_ROLE_SWAPS; ··· 986 984 987 985 if (cur_role == role) 988 986 goto out_unlock; 987 + 988 + reinit_completion(&con->complete); 989 989 990 990 command = UCSI_SET_PDR | UCSI_CONNECTOR_NUMBER(con->num); 991 991 command |= UCSI_SET_PDR_ROLE(role);