Skip to contentSkip to conversation

i3c: dw: Complete exception handling in dw_i3c_master_i3c_xfers()

PATCH In review Markus Elfring 2 participants 2 messages Mar 1 – Mar 2

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i3c: dw: Complete exception handling in dw_i3c_master_i3c_xfers()

From: Markus Elfring <[email protected]>
Date: Sun, 1 Mar 2026 19:11:51 +0100

A dw_i3c_xfer structure is allocated by a dw_i3c_master_alloc_xfer() call. It is not released after a failed pm_runtime_resume_and_get() call.

Thus use an additional label so that the affected memory is always be freed at the end of this function implementation.

This issue was detected by using the Coccinelle software.

Fixes 62fe9d06f5709caa1fa68055873ff279e05ade37 ("i3c: dw: Add power management support")
---
 drivers/i3c/master/dw-i3c-master.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i3c/master/dw-i3c-master.c +3 -3
index d87bde3f7700..723f185584d0 100644
@@ -953,7 +953,7 @@ static int dw_i3c_master_i3c_xfers(struct i3c_dev_desc *dev,
 		dev_err(master->dev,
 			"<%s> cannot resume i3c bus master, err: %d\n",
 			__func__, ret);
-		return ret;
+		goto free_xfer;
 	}
 
 	for (i = 0; i < i3c_nxfers; i++) {
@@ -994,10 +994,10 @@ static int dw_i3c_master_i3c_xfers(struct i3c_dev_desc *dev,
 			i3c_xfers[i].len = cmd->rx_len;
 	}
 
+	pm_runtime_put_autosuspend(master->dev);
 	ret = xfer->ret;
+free_xfer:
 	dw_i3c_master_free_xfer(xfer);
-
-	pm_runtime_put_autosuspend(master->dev);
 	return ret;
 }
 
Signature · 1 line
2.53.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 1 Mar 2026 19:11:51 +0100

A dw_i3c_xfer structure is allocated by a dw_i3c_master_alloc_xfer() call. It is not released after a failed pm_runtime_resume_and_get() call.

Thus use an additional label so that the affected memory is always be freed at the end of this function implementation.

Quoted 6 lines

This issue was detected by using the Coccinelle software.

Fixes 62fe9d06f5709caa1fa68055873ff279e05ade37 ("i3c: dw: Add power management support")

---

Quoted 32 lines
 drivers/i3c/master/dw-i3c-master.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i3c/master/dw-i3c-master.c +3 -4
index d87bde3f7700..723f185584d0 100644
@@ -953,7 +953,7 @@ static int dw_i3c_master_i3c_xfers(struct i3c_dev_desc *dev,
 		dev_err(master->dev,
 			"<%s> cannot resume i3c bus master, err: %d\n",
 			__func__, ret);
-		return ret;
+		goto free_xfer;
 	}
 
 	for (i = 0; i < i3c_nxfers; i++) {
@@ -994,10 +994,10 @@ static int dw_i3c_master_i3c_xfers(struct i3c_dev_desc *dev,
 			i3c_xfers[i].len = cmd->rx_len;
 	}
 
+	pm_runtime_put_autosuspend(master->dev);
 	ret = xfer->ret;
+free_xfer:
 	dw_i3c_master_free_xfer(xfer);
-
-	pm_runtime_put_autosuspend(master->dev);
 	return ret;
 }
 
--

2.53.0