[RFT] usb: typec: ucsi: Fix a potential deadlock in ucsi_send_command_common()
Luca Coelho
luciano.coelho at intel.com
Mon Aug 5 15:02:30 UTC 2024
From: Heikki Krogerus <heikki.krogerus at linux.intel.com>
The function returns with the ppm_lock held if there's an
error or the PPM reports BUSY condition.
Reported-by: Luciano Coelho <luciano.coelho at intel.com>
Fixes: 5e9c1662a89b ("usb: typec: ucsi: rework command execution functions")
Cc: stable at vger.kernel.org
Signed-off-by: Heikki Krogerus <heikki.krogerus at linux.intel.com>
Signed-off-by: Luca Coelho <luciano.coelho at intel.com>
---
Hi,
I'm sending this here just for testing, I hope it's not a problem.
This is the only way we found out how to trigger a CI run for Xe.
This patch should fix a regression in typec-ucsi so we should get more
Xe CI results with it.
Cheers,
Luca.
drivers/usb/typec/ucsi/ucsi.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index dcd3765cc1f5..432a2d6266d7 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -238,13 +238,10 @@ static int ucsi_send_command_common(struct ucsi *ucsi, u64 cmd,
mutex_lock(&ucsi->ppm_lock);
ret = ucsi_run_command(ucsi, cmd, &cci, data, size, conn_ack);
- if (cci & UCSI_CCI_BUSY) {
- ret = ucsi_run_command(ucsi, UCSI_CANCEL, &cci, NULL, 0, false);
- return ret ? ret : -EBUSY;
- }
-
- if (cci & UCSI_CCI_ERROR)
- return ucsi_read_error(ucsi, connector_num);
+ if (cci & UCSI_CCI_BUSY)
+ ret = ucsi_run_command(ucsi, UCSI_CANCEL, &cci, NULL, 0, false) ?: -EBUSY;
+ else if (cci & UCSI_CCI_ERROR)
+ ret = ucsi_read_error(ucsi, connector_num);
mutex_unlock(&ucsi->ppm_lock);
return ret;
--
2.39.2
More information about the Intel-xe
mailing list