i3c: dw: Complete exception handling in dw_i3c_master_i3c_xfers()
Subsystems (3)
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.
--- drivers/i3c/master/dw-i3c-master.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i3c/master/dw-i3c-master.c +3 -3
@@ -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
Quoted 9 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 1 Mar 2026 19:11:51 +0100A
dw_i3c_xferstructure is allocated by adw_i3c_master_alloc_xfer()call. It is not released after a failedpm_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")Signed-off-by Markus Elfring <[email protected]>---
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@@ -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