Commit 099cf1fb authored by Andrei Kuchynski's avatar Andrei Kuchynski Committed by Greg Kroah-Hartman
Browse files

usb: typec: displayport: Fix potential deadlock



The deadlock can occur due to a recursive lock acquisition of
`cros_typec_altmode_data::mutex`.
The call chain is as follows:
1. cros_typec_altmode_work() acquires the mutex
2. typec_altmode_vdm() -> dp_altmode_vdm() ->
3. typec_altmode_exit() -> cros_typec_altmode_exit()
4. cros_typec_altmode_exit() attempts to acquire the mutex again

To prevent this, defer the `typec_altmode_exit()` call by scheduling
it rather than calling it directly from within the mutex-protected
context.

Cc: stable <stable@kernel.org>
Fixes: b4b38ffb ("usb: typec: displayport: Receive DP Status Update NAK request exit dp altmode")
Signed-off-by: default avatarAndrei Kuchynski <akuchynski@chromium.org>
Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20250624133246.3936737-1-akuchynski@chromium.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent af4db5a3
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -394,8 +394,7 @@ static int dp_altmode_vdm(struct typec_altmode *alt,
	case CMDT_RSP_NAK:
		switch (cmd) {
		case DP_CMD_STATUS_UPDATE:
			if (typec_altmode_exit(alt))
				dev_err(&dp->alt->dev, "Exit Mode Failed!\n");
			dp->state = DP_STATE_EXIT;
			break;
		case DP_CMD_CONFIGURE:
			dp->data.conf = 0;