[PATCH v2] bus/fslmc: unlock spinlock in case of timeout

Alvaro Karsz alvaro.karsz at solid-run.com
Mon Dec 26 08:47:09 CET 2022


Bug in function mc_send_command,
A spinlock is not unlocked in case of timeouts.

Fixes: 79711846f676 ("bus/fslmc: add timeout in MC send command")
Signed-off-by: Alvaro Karsz <alvaro.karsz at solid-run.com>
--
v2:
	- Fix code indentation.
	- Fix "Fixes: " tag format.
---
 drivers/bus/fslmc/mc/mc_sys.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/fslmc/mc/mc_sys.c b/drivers/bus/fslmc/mc/mc_sys.c
index ab9a074835..018bd9990e 100644
--- a/drivers/bus/fslmc/mc/mc_sys.c
+++ b/drivers/bus/fslmc/mc/mc_sys.c
@@ -77,8 +77,12 @@ int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd)
 		total_time = rte_get_timer_cycles() - start_time;
 	} while (status == MC_CMD_STATUS_READY && total_time <= time_to_wait);
 
-	if (status == MC_CMD_STATUS_READY)
+	if (status == MC_CMD_STATUS_READY) {
+		/* --- Call unlock function here in case portal is shared --- */
+		rte_spinlock_unlock(&mc_portal_lock);
+
 		return mc_status_to_error(MC_CMD_STATUS_TIMEOUT);
+	}
 
 	/* Read the response back into the command buffer */
 	mc_read_response(mc_io->regs, cmd);
-- 
2.32.0



More information about the dev mailing list