* [PATCH] i3c: dw: Complete exception handling in dw_i3c_master_i3c_xfers()
@ 2026-03-01 18:25 Markus Elfring
2026-03-02 20:25 ` Frank Li
0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2026-03-01 18:25 UTC (permalink / raw)
To: linux-i3c, Adrian Ng Ho Yin, Alexandre Belloni, Aniket, Frank Li,
Fredrik Markstrom, Ivar Holmqvist, Jorge Marques,
Manikanta Guntupalli, Sakari Ailus, Wolfram Sang, Zilin Guan
Cc: LKML, kernel-janitors, cocci, Jianhao Xu, Nuno Sá
From: Markus Elfring <elfring@users.sourceforge.net>
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")
Cc: stable@vger.kernel.org
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/i3c/master/dw-i3c-master.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
index d87bde3f7700..723f185584d0 100644
--- a/drivers/i3c/master/dw-i3c-master.c
+++ b/drivers/i3c/master/dw-i3c-master.c
@@ -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
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] i3c: dw: Complete exception handling in dw_i3c_master_i3c_xfers()
2026-03-01 18:25 [PATCH] i3c: dw: Complete exception handling in dw_i3c_master_i3c_xfers() Markus Elfring
@ 2026-03-02 20:25 ` Frank Li
0 siblings, 0 replies; 2+ messages in thread
From: Frank Li @ 2026-03-02 20:25 UTC (permalink / raw)
To: Markus Elfring
Cc: linux-i3c, Adrian Ng Ho Yin, Alexandre Belloni, Aniket,
Fredrik Markstrom, Ivar Holmqvist, Jorge Marques,
Manikanta Guntupalli, Sakari Ailus, Wolfram Sang, Zilin Guan,
LKML, kernel-janitors, cocci, Jianhao Xu, Nuno Sá
On Sun, Mar 01, 2026 at 07:25:51PM +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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")
> Cc: stable@vger.kernel.org
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> drivers/i3c/master/dw-i3c-master.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
> index d87bde3f7700..723f185584d0 100644
> --- a/drivers/i3c/master/dw-i3c-master.c
> +++ b/drivers/i3c/master/dw-i3c-master.c
> @@ -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
>
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-02 20:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-01 18:25 [PATCH] i3c: dw: Complete exception handling in dw_i3c_master_i3c_xfers() Markus Elfring
2026-03-02 20:25 ` Frank Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox