Commit 65ba8cef authored by Heikki Krogerus's avatar Heikki Krogerus Committed by Greg Kroah-Hartman

usb: typec: ucsi: Fix a deadlock in ucsi_send_command_common()

The function returns with the ppm_lock held if the PPM is
busy or there's an error.
Reported-and-tested-by: default avatarLuciano Coelho <luciano.coelho@intel.com>
Fixes: 5e9c1662 ("usb: typec: ucsi: rework command execution functions")
Signed-off-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Reported-by: default avatarLuciano Coelho <luciano.coelho@intel.com>
Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/20240806112029.2984319-1-heikki.krogerus@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent becac61a
...@@ -238,13 +238,10 @@ static int ucsi_send_command_common(struct ucsi *ucsi, u64 cmd, ...@@ -238,13 +238,10 @@ static int ucsi_send_command_common(struct ucsi *ucsi, u64 cmd,
mutex_lock(&ucsi->ppm_lock); mutex_lock(&ucsi->ppm_lock);
ret = ucsi_run_command(ucsi, cmd, &cci, data, size, conn_ack); ret = ucsi_run_command(ucsi, cmd, &cci, data, size, conn_ack);
if (cci & UCSI_CCI_BUSY) { if (cci & UCSI_CCI_BUSY)
ret = ucsi_run_command(ucsi, UCSI_CANCEL, &cci, NULL, 0, false); ret = ucsi_run_command(ucsi, UCSI_CANCEL, &cci, NULL, 0, false) ?: -EBUSY;
return ret ? ret : -EBUSY; else if (cci & UCSI_CCI_ERROR)
} ret = ucsi_read_error(ucsi, connector_num);
if (cci & UCSI_CCI_ERROR)
return ucsi_read_error(ucsi, connector_num);
mutex_unlock(&ucsi->ppm_lock); mutex_unlock(&ucsi->ppm_lock);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment