* [PATCH v3 0/2] i3c: dw: Fix memory leak in dw_i3c_master_i3c_xfers()
@ 2026-04-04 10:32 Felix Gu
2026-04-04 10:32 ` [PATCH v3 1/2] " Felix Gu
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Felix Gu @ 2026-04-04 10:32 UTC (permalink / raw)
To: Alexandre Belloni, Frank Li, Aniket; +Cc: linux-i3c, linux-kernel, Felix Gu
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
Changes in v3:
- Refine the commit message.
- Simplify the xfer cleanup using __free(kfree).
- Link to v2: https://lore.kernel.org/r/20260402-dw-i3c-2-v2-1-aa6c81d392da@gmail.com
Changes in v2:
- Switch to use __free(kfree) to automatically free the memory.
- Link to v1: https://lore.kernel.org/r/20260402-dw-i3c-2-v1-1-b530970654ec@gmail.com
---
Felix Gu (2):
i3c: dw: Fix memory leak in dw_i3c_master_i3c_xfers()
i3c: dw: Simplify xfer cleanup with __free(kfree)
drivers/i3c/master/dw-i3c-master.c | 38 +++++++++-----------------------------
1 file changed, 9 insertions(+), 29 deletions(-)
---
base-commit: bd0f139e5fc11182777b81cefc3893ea508544ec
change-id: 20260402-dw-i3c-2-8f123def99b2
Best regards,
--
Felix Gu <ustc.gu@gmail.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 1/2] i3c: dw: Fix memory leak in dw_i3c_master_i3c_xfers()
2026-04-04 10:32 [PATCH v3 0/2] i3c: dw: Fix memory leak in dw_i3c_master_i3c_xfers() Felix Gu
@ 2026-04-04 10:32 ` Felix Gu
2026-04-06 2:59 ` Frank Li
2026-04-06 3:05 ` Frank Li
2026-04-04 10:32 ` [PATCH v3 2/2] i3c: dw: Simplify xfer cleanup with __free(kfree) Felix Gu
2026-04-12 14:52 ` [PATCH v3 0/2] i3c: dw: Fix memory leak in dw_i3c_master_i3c_xfers() Alexandre Belloni
2 siblings, 2 replies; 8+ messages in thread
From: Felix Gu @ 2026-04-04 10:32 UTC (permalink / raw)
To: Alexandre Belloni, Frank Li, Aniket; +Cc: linux-i3c, linux-kernel, Felix Gu
The dw_i3c_master_i3c_xfers() function allocates memory for the xfer
structure using dw_i3c_master_alloc_xfer(). If pm_runtime_resume_and_get()
fails, the function returns without freeing the allocated xfer, resulting
in a memory leak.
Since dw_i3c_master_free_xfer() is a thin wrapper around kfree(), use
the __free(kfree) cleanup attribute to handle the free automatically on
all exit paths.
Fixes: 62fe9d06f570 ("i3c: dw: Add power management support")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
drivers/i3c/master/dw-i3c-master.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
index d6bdb32397fb..2e31228b3809 100644
--- a/drivers/i3c/master/dw-i3c-master.c
+++ b/drivers/i3c/master/dw-i3c-master.c
@@ -7,6 +7,7 @@
#include <linux/bitfield.h>
#include <linux/bitops.h>
+#include <linux/cleanup.h>
#include <linux/clk.h>
#include <linux/completion.h>
#include <linux/err.h>
@@ -924,7 +925,6 @@ static int dw_i3c_master_i3c_xfers(struct i3c_dev_desc *dev,
struct i3c_master_controller *m = i3c_dev_get_master(dev);
struct dw_i3c_master *master = to_dw_i3c_master(m);
unsigned int nrxwords = 0, ntxwords = 0;
- struct dw_i3c_xfer *xfer;
int i, ret = 0;
if (!i3c_nxfers)
@@ -944,7 +944,7 @@ static int dw_i3c_master_i3c_xfers(struct i3c_dev_desc *dev,
nrxwords > master->caps.datafifodepth)
return -EOPNOTSUPP;
- xfer = dw_i3c_master_alloc_xfer(master, i3c_nxfers);
+ struct dw_i3c_xfer *xfer __free(kfree) = dw_i3c_master_alloc_xfer(master, i3c_nxfers);
if (!xfer)
return -ENOMEM;
@@ -995,7 +995,6 @@ static int dw_i3c_master_i3c_xfers(struct i3c_dev_desc *dev,
}
ret = xfer->ret;
- dw_i3c_master_free_xfer(xfer);
pm_runtime_put_autosuspend(master->dev);
return ret;
--
2.43.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 2/2] i3c: dw: Simplify xfer cleanup with __free(kfree)
2026-04-04 10:32 [PATCH v3 0/2] i3c: dw: Fix memory leak in dw_i3c_master_i3c_xfers() Felix Gu
2026-04-04 10:32 ` [PATCH v3 1/2] " Felix Gu
@ 2026-04-04 10:32 ` Felix Gu
2026-04-06 3:03 ` Frank Li
2026-04-12 14:52 ` [PATCH v3 0/2] i3c: dw: Fix memory leak in dw_i3c_master_i3c_xfers() Alexandre Belloni
2 siblings, 1 reply; 8+ messages in thread
From: Felix Gu @ 2026-04-04 10:32 UTC (permalink / raw)
To: Alexandre Belloni, Frank Li, Aniket; +Cc: linux-i3c, linux-kernel, Felix Gu
Convert dw-i3c-master to use __free(kfree) guards for struct dw_i3c_xfer
allocations. This frees xfer objects automatically on scope exit, and
removes the now-unused dw_i3c_master_free_xfer() helper.
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
drivers/i3c/master/dw-i3c-master.c | 33 +++++++--------------------------
1 file changed, 7 insertions(+), 26 deletions(-)
diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
index 2e31228b3809..41ef37115f8b 100644
--- a/drivers/i3c/master/dw-i3c-master.c
+++ b/drivers/i3c/master/dw-i3c-master.c
@@ -394,11 +394,6 @@ dw_i3c_master_alloc_xfer(struct dw_i3c_master *master, unsigned int ncmds)
return xfer;
}
-static void dw_i3c_master_free_xfer(struct dw_i3c_xfer *xfer)
-{
- kfree(xfer);
-}
-
static void dw_i3c_master_start_xfer_locked(struct dw_i3c_master *master)
{
struct dw_i3c_xfer *xfer = master->xferqueue.cur;
@@ -716,7 +711,6 @@ static void dw_i3c_master_bus_cleanup(struct i3c_master_controller *m)
static int dw_i3c_ccc_set(struct dw_i3c_master *master,
struct i3c_ccc_cmd *ccc)
{
- struct dw_i3c_xfer *xfer;
struct dw_i3c_cmd *cmd;
int ret, pos = 0;
@@ -726,7 +720,7 @@ static int dw_i3c_ccc_set(struct dw_i3c_master *master,
return pos;
}
- xfer = dw_i3c_master_alloc_xfer(master, 1);
+ struct dw_i3c_xfer *xfer __free(kfree) = dw_i3c_master_alloc_xfer(master, 1);
if (!xfer)
return -ENOMEM;
@@ -751,14 +745,11 @@ static int dw_i3c_ccc_set(struct dw_i3c_master *master,
if (xfer->cmds[0].error == RESPONSE_ERROR_IBA_NACK)
ccc->err = I3C_ERROR_M2;
- dw_i3c_master_free_xfer(xfer);
-
return ret;
}
static int dw_i3c_ccc_get(struct dw_i3c_master *master, struct i3c_ccc_cmd *ccc)
{
- struct dw_i3c_xfer *xfer;
struct dw_i3c_cmd *cmd;
int ret, pos;
@@ -766,7 +757,7 @@ static int dw_i3c_ccc_get(struct dw_i3c_master *master, struct i3c_ccc_cmd *ccc)
if (pos < 0)
return pos;
- xfer = dw_i3c_master_alloc_xfer(master, 1);
+ struct dw_i3c_xfer *xfer __free(kfree) = dw_i3c_master_alloc_xfer(master, 1);
if (!xfer)
return -ENOMEM;
@@ -791,7 +782,6 @@ static int dw_i3c_ccc_get(struct dw_i3c_master *master, struct i3c_ccc_cmd *ccc)
ret = xfer->ret;
if (xfer->cmds[0].error == RESPONSE_ERROR_IBA_NACK)
ccc->err = I3C_ERROR_M2;
- dw_i3c_master_free_xfer(xfer);
return ret;
}
@@ -838,12 +828,15 @@ static int dw_i3c_master_send_ccc_cmd(struct i3c_master_controller *m,
static int dw_i3c_master_daa(struct i3c_master_controller *m)
{
struct dw_i3c_master *master = to_dw_i3c_master(m);
- struct dw_i3c_xfer *xfer;
struct dw_i3c_cmd *cmd;
u32 olddevs, newdevs;
u8 last_addr = 0;
int ret, pos;
+ struct dw_i3c_xfer *xfer __free(kfree) = dw_i3c_master_alloc_xfer(master, 1);
+ if (!xfer)
+ return -ENOMEM;
+
ret = pm_runtime_resume_and_get(master->dev);
if (ret < 0) {
dev_err(master->dev,
@@ -877,15 +870,8 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)
ret = 0;
}
- xfer = dw_i3c_master_alloc_xfer(master, 1);
- if (!xfer) {
- ret = -ENOMEM;
- goto rpm_out;
- }
-
pos = dw_i3c_master_get_free_pos(master);
if (pos < 0) {
- dw_i3c_master_free_xfer(xfer);
ret = pos;
goto rpm_out;
}
@@ -910,8 +896,6 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)
i3c_master_add_i3c_dev_locked(m, master->devs[pos].addr);
}
- dw_i3c_master_free_xfer(xfer);
-
rpm_out:
pm_runtime_put_autosuspend(master->dev);
return ret;
@@ -1083,7 +1067,6 @@ static int dw_i3c_master_i2c_xfers(struct i2c_dev_desc *dev,
struct i3c_master_controller *m = i2c_dev_get_master(dev);
struct dw_i3c_master *master = to_dw_i3c_master(m);
unsigned int nrxwords = 0, ntxwords = 0;
- struct dw_i3c_xfer *xfer;
int i, ret = 0;
if (!i2c_nxfers)
@@ -1103,7 +1086,7 @@ static int dw_i3c_master_i2c_xfers(struct i2c_dev_desc *dev,
nrxwords > master->caps.datafifodepth)
return -EOPNOTSUPP;
- xfer = dw_i3c_master_alloc_xfer(master, i2c_nxfers);
+ struct dw_i3c_xfer *xfer __free(kfree) = dw_i3c_master_alloc_xfer(master, i2c_nxfers);
if (!xfer)
return -ENOMEM;
@@ -1112,7 +1095,6 @@ static int dw_i3c_master_i2c_xfers(struct i2c_dev_desc *dev,
dev_err(master->dev,
"<%s> cannot resume i3c bus master, err: %d\n",
__func__, ret);
- dw_i3c_master_free_xfer(xfer);
return ret;
}
@@ -1144,7 +1126,6 @@ static int dw_i3c_master_i2c_xfers(struct i2c_dev_desc *dev,
dw_i3c_master_dequeue_xfer(master, xfer);
ret = xfer->ret;
- dw_i3c_master_free_xfer(xfer);
pm_runtime_put_autosuspend(master->dev);
return ret;
--
2.43.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 1/2] i3c: dw: Fix memory leak in dw_i3c_master_i3c_xfers()
2026-04-04 10:32 ` [PATCH v3 1/2] " Felix Gu
@ 2026-04-06 2:59 ` Frank Li
2026-04-06 3:05 ` Frank Li
1 sibling, 0 replies; 8+ messages in thread
From: Frank Li @ 2026-04-06 2:59 UTC (permalink / raw)
To: Felix Gu; +Cc: Alexandre Belloni, Aniket, linux-i3c, linux-kernel
On Sat, Apr 04, 2026 at 06:32:30PM +0800, Felix Gu wrote:
> The dw_i3c_master_i3c_xfers() function allocates memory for the xfer
> structure using dw_i3c_master_alloc_xfer(). If pm_runtime_resume_and_get()
> fails, the function returns without freeing the allocated xfer, resulting
> in a memory leak.
>
> Since dw_i3c_master_free_xfer() is a thin wrapper around kfree(), use
> the __free(kfree) cleanup attribute to handle the free automatically on
> all exit paths.
>
> Fixes: 62fe9d06f570 ("i3c: dw: Add power management support")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> drivers/i3c/master/dw-i3c-master.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
> index d6bdb32397fb..2e31228b3809 100644
> --- a/drivers/i3c/master/dw-i3c-master.c
> +++ b/drivers/i3c/master/dw-i3c-master.c
> @@ -7,6 +7,7 @@
>
> #include <linux/bitfield.h>
> #include <linux/bitops.h>
> +#include <linux/cleanup.h>
> #include <linux/clk.h>
> #include <linux/completion.h>
> #include <linux/err.h>
> @@ -924,7 +925,6 @@ static int dw_i3c_master_i3c_xfers(struct i3c_dev_desc *dev,
> struct i3c_master_controller *m = i3c_dev_get_master(dev);
> struct dw_i3c_master *master = to_dw_i3c_master(m);
> unsigned int nrxwords = 0, ntxwords = 0;
> - struct dw_i3c_xfer *xfer;
> int i, ret = 0;
>
> if (!i3c_nxfers)
> @@ -944,7 +944,7 @@ static int dw_i3c_master_i3c_xfers(struct i3c_dev_desc *dev,
> nrxwords > master->caps.datafifodepth)
> return -EOPNOTSUPP;
>
> - xfer = dw_i3c_master_alloc_xfer(master, i3c_nxfers);
> + struct dw_i3c_xfer *xfer __free(kfree) = dw_i3c_master_alloc_xfer(master, i3c_nxfers);
> if (!xfer)
> return -ENOMEM;
>
> @@ -995,7 +995,6 @@ static int dw_i3c_master_i3c_xfers(struct i3c_dev_desc *dev,
> }
>
> ret = xfer->ret;
> - dw_i3c_master_free_xfer(xfer);
>
> pm_runtime_put_autosuspend(master->dev);
> return ret;
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 2/2] i3c: dw: Simplify xfer cleanup with __free(kfree)
2026-04-04 10:32 ` [PATCH v3 2/2] i3c: dw: Simplify xfer cleanup with __free(kfree) Felix Gu
@ 2026-04-06 3:03 ` Frank Li
0 siblings, 0 replies; 8+ messages in thread
From: Frank Li @ 2026-04-06 3:03 UTC (permalink / raw)
To: Felix Gu; +Cc: Alexandre Belloni, Aniket, linux-i3c, linux-kernel
On Sat, Apr 04, 2026 at 06:32:31PM +0800, Felix Gu wrote:
> Convert dw-i3c-master to use __free(kfree) guards for struct dw_i3c_xfer
> allocations. This frees xfer objects automatically on scope exit, and
> removes the now-unused dw_i3c_master_free_xfer() helper.
>
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---
> drivers/i3c/master/dw-i3c-master.c | 33 +++++++--------------------------
> 1 file changed, 7 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
> index 2e31228b3809..41ef37115f8b 100644
> --- a/drivers/i3c/master/dw-i3c-master.c
> +++ b/drivers/i3c/master/dw-i3c-master.c
> @@ -394,11 +394,6 @@ dw_i3c_master_alloc_xfer(struct dw_i3c_master *master, unsigned int ncmds)
> return xfer;
> }
>
> -static void dw_i3c_master_free_xfer(struct dw_i3c_xfer *xfer)
> -{
> - kfree(xfer);
> -}
> -
> static void dw_i3c_master_start_xfer_locked(struct dw_i3c_master *master)
> {
> struct dw_i3c_xfer *xfer = master->xferqueue.cur;
> @@ -716,7 +711,6 @@ static void dw_i3c_master_bus_cleanup(struct i3c_master_controller *m)
> static int dw_i3c_ccc_set(struct dw_i3c_master *master,
> struct i3c_ccc_cmd *ccc)
> {
> - struct dw_i3c_xfer *xfer;
> struct dw_i3c_cmd *cmd;
> int ret, pos = 0;
>
> @@ -726,7 +720,7 @@ static int dw_i3c_ccc_set(struct dw_i3c_master *master,
> return pos;
> }
>
> - xfer = dw_i3c_master_alloc_xfer(master, 1);
> + struct dw_i3c_xfer *xfer __free(kfree) = dw_i3c_master_alloc_xfer(master, 1);
> if (!xfer)
> return -ENOMEM;
>
> @@ -751,14 +745,11 @@ static int dw_i3c_ccc_set(struct dw_i3c_master *master,
> if (xfer->cmds[0].error == RESPONSE_ERROR_IBA_NACK)
> ccc->err = I3C_ERROR_M2;
>
> - dw_i3c_master_free_xfer(xfer);
> -
> return ret;
> }
>
> static int dw_i3c_ccc_get(struct dw_i3c_master *master, struct i3c_ccc_cmd *ccc)
> {
> - struct dw_i3c_xfer *xfer;
> struct dw_i3c_cmd *cmd;
> int ret, pos;
>
> @@ -766,7 +757,7 @@ static int dw_i3c_ccc_get(struct dw_i3c_master *master, struct i3c_ccc_cmd *ccc)
> if (pos < 0)
> return pos;
>
> - xfer = dw_i3c_master_alloc_xfer(master, 1);
> + struct dw_i3c_xfer *xfer __free(kfree) = dw_i3c_master_alloc_xfer(master, 1);
> if (!xfer)
> return -ENOMEM;
>
> @@ -791,7 +782,6 @@ static int dw_i3c_ccc_get(struct dw_i3c_master *master, struct i3c_ccc_cmd *ccc)
> ret = xfer->ret;
> if (xfer->cmds[0].error == RESPONSE_ERROR_IBA_NACK)
> ccc->err = I3C_ERROR_M2;
> - dw_i3c_master_free_xfer(xfer);
>
> return ret;
> }
> @@ -838,12 +828,15 @@ static int dw_i3c_master_send_ccc_cmd(struct i3c_master_controller *m,
> static int dw_i3c_master_daa(struct i3c_master_controller *m)
> {
> struct dw_i3c_master *master = to_dw_i3c_master(m);
> - struct dw_i3c_xfer *xfer;
> struct dw_i3c_cmd *cmd;
> u32 olddevs, newdevs;
> u8 last_addr = 0;
> int ret, pos;
>
> + struct dw_i3c_xfer *xfer __free(kfree) = dw_i3c_master_alloc_xfer(master, 1);
> + if (!xfer)
> + return -ENOMEM;
> +
> ret = pm_runtime_resume_and_get(master->dev);
> if (ret < 0) {
> dev_err(master->dev,
> @@ -877,15 +870,8 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)
> ret = 0;
> }
>
> - xfer = dw_i3c_master_alloc_xfer(master, 1);
> - if (!xfer) {
> - ret = -ENOMEM;
> - goto rpm_out;
> - }
> -
> pos = dw_i3c_master_get_free_pos(master);
> if (pos < 0) {
> - dw_i3c_master_free_xfer(xfer);
> ret = pos;
> goto rpm_out;
> }
> @@ -910,8 +896,6 @@ static int dw_i3c_master_daa(struct i3c_master_controller *m)
> i3c_master_add_i3c_dev_locked(m, master->devs[pos].addr);
> }
>
> - dw_i3c_master_free_xfer(xfer);
> -
> rpm_out:
> pm_runtime_put_autosuspend(master->dev);
> return ret;
> @@ -1083,7 +1067,6 @@ static int dw_i3c_master_i2c_xfers(struct i2c_dev_desc *dev,
> struct i3c_master_controller *m = i2c_dev_get_master(dev);
> struct dw_i3c_master *master = to_dw_i3c_master(m);
> unsigned int nrxwords = 0, ntxwords = 0;
> - struct dw_i3c_xfer *xfer;
> int i, ret = 0;
>
> if (!i2c_nxfers)
> @@ -1103,7 +1086,7 @@ static int dw_i3c_master_i2c_xfers(struct i2c_dev_desc *dev,
> nrxwords > master->caps.datafifodepth)
> return -EOPNOTSUPP;
>
> - xfer = dw_i3c_master_alloc_xfer(master, i2c_nxfers);
> + struct dw_i3c_xfer *xfer __free(kfree) = dw_i3c_master_alloc_xfer(master, i2c_nxfers);
> if (!xfer)
> return -ENOMEM;
>
> @@ -1112,7 +1095,6 @@ static int dw_i3c_master_i2c_xfers(struct i2c_dev_desc *dev,
> dev_err(master->dev,
> "<%s> cannot resume i3c bus master, err: %d\n",
> __func__, ret);
> - dw_i3c_master_free_xfer(xfer);
> return ret;
> }
>
> @@ -1144,7 +1126,6 @@ static int dw_i3c_master_i2c_xfers(struct i2c_dev_desc *dev,
> dw_i3c_master_dequeue_xfer(master, xfer);
>
> ret = xfer->ret;
> - dw_i3c_master_free_xfer(xfer);
>
> pm_runtime_put_autosuspend(master->dev);
> return ret;
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 1/2] i3c: dw: Fix memory leak in dw_i3c_master_i3c_xfers()
2026-04-04 10:32 ` [PATCH v3 1/2] " Felix Gu
2026-04-06 2:59 ` Frank Li
@ 2026-04-06 3:05 ` Frank Li
2026-04-06 6:52 ` Felix Gu
1 sibling, 1 reply; 8+ messages in thread
From: Frank Li @ 2026-04-06 3:05 UTC (permalink / raw)
To: Felix Gu; +Cc: Alexandre Belloni, Aniket, linux-i3c, linux-kernel
On Sat, Apr 04, 2026 at 06:32:30PM +0800, Felix Gu wrote:
> The dw_i3c_master_i3c_xfers() function allocates memory for the xfer
> structure using dw_i3c_master_alloc_xfer(). If pm_runtime_resume_and_get()
> fails, the function returns without freeing the allocated xfer, resulting
> in a memory leak.
>
> Since dw_i3c_master_free_xfer() is a thin wrapper around kfree(), use
> the __free(kfree) cleanup attribute to handle the free automatically on
> all exit paths.
>
> Fixes: 62fe9d06f570 ("i3c: dw: Add power management support")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> ---
You misssed Tommaso Merciai review tags in v2
Frank
> drivers/i3c/master/dw-i3c-master.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
> index d6bdb32397fb..2e31228b3809 100644
> --- a/drivers/i3c/master/dw-i3c-master.c
> +++ b/drivers/i3c/master/dw-i3c-master.c
> @@ -7,6 +7,7 @@
>
> #include <linux/bitfield.h>
> #include <linux/bitops.h>
> +#include <linux/cleanup.h>
> #include <linux/clk.h>
> #include <linux/completion.h>
> #include <linux/err.h>
> @@ -924,7 +925,6 @@ static int dw_i3c_master_i3c_xfers(struct i3c_dev_desc *dev,
> struct i3c_master_controller *m = i3c_dev_get_master(dev);
> struct dw_i3c_master *master = to_dw_i3c_master(m);
> unsigned int nrxwords = 0, ntxwords = 0;
> - struct dw_i3c_xfer *xfer;
> int i, ret = 0;
>
> if (!i3c_nxfers)
> @@ -944,7 +944,7 @@ static int dw_i3c_master_i3c_xfers(struct i3c_dev_desc *dev,
> nrxwords > master->caps.datafifodepth)
> return -EOPNOTSUPP;
>
> - xfer = dw_i3c_master_alloc_xfer(master, i3c_nxfers);
> + struct dw_i3c_xfer *xfer __free(kfree) = dw_i3c_master_alloc_xfer(master, i3c_nxfers);
> if (!xfer)
> return -ENOMEM;
>
> @@ -995,7 +995,6 @@ static int dw_i3c_master_i3c_xfers(struct i3c_dev_desc *dev,
> }
>
> ret = xfer->ret;
> - dw_i3c_master_free_xfer(xfer);
>
> pm_runtime_put_autosuspend(master->dev);
> return ret;
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 1/2] i3c: dw: Fix memory leak in dw_i3c_master_i3c_xfers()
2026-04-06 3:05 ` Frank Li
@ 2026-04-06 6:52 ` Felix Gu
0 siblings, 0 replies; 8+ messages in thread
From: Felix Gu @ 2026-04-06 6:52 UTC (permalink / raw)
To: Frank Li; +Cc: Alexandre Belloni, Aniket, linux-i3c, linux-kernel
On Mon, Apr 6, 2026 at 11:05 AM Frank Li <Frank.li@nxp.com> wrote:
>
>
> You misssed Tommaso Merciai review tags in v2
>
> Frank
Hi Frank,
You mixed up the review, Tommaso Merciai review tags is for another review.
https://lore.kernel.org/lkml/ac922Ua3UjbZXdPV@tom-desktop/
Best Regards,
Felix Gu
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 0/2] i3c: dw: Fix memory leak in dw_i3c_master_i3c_xfers()
2026-04-04 10:32 [PATCH v3 0/2] i3c: dw: Fix memory leak in dw_i3c_master_i3c_xfers() Felix Gu
2026-04-04 10:32 ` [PATCH v3 1/2] " Felix Gu
2026-04-04 10:32 ` [PATCH v3 2/2] i3c: dw: Simplify xfer cleanup with __free(kfree) Felix Gu
@ 2026-04-12 14:52 ` Alexandre Belloni
2 siblings, 0 replies; 8+ messages in thread
From: Alexandre Belloni @ 2026-04-12 14:52 UTC (permalink / raw)
To: Frank Li, Aniket, Felix Gu; +Cc: linux-i3c, linux-kernel
On Sat, 04 Apr 2026 18:32:29 +0800, Felix Gu wrote:
>
Applied, thanks!
[1/2] i3c: dw: Fix memory leak in dw_i3c_master_i3c_xfers()
https://git.kernel.org/i3c/c/256cc1f1305a
[2/2] i3c: dw: Simplify xfer cleanup with __free(kfree)
https://git.kernel.org/i3c/c/6105f4919615
Best regards,
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-04-12 14:53 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-04 10:32 [PATCH v3 0/2] i3c: dw: Fix memory leak in dw_i3c_master_i3c_xfers() Felix Gu
2026-04-04 10:32 ` [PATCH v3 1/2] " Felix Gu
2026-04-06 2:59 ` Frank Li
2026-04-06 3:05 ` Frank Li
2026-04-06 6:52 ` Felix Gu
2026-04-04 10:32 ` [PATCH v3 2/2] i3c: dw: Simplify xfer cleanup with __free(kfree) Felix Gu
2026-04-06 3:03 ` Frank Li
2026-04-12 14:52 ` [PATCH v3 0/2] i3c: dw: Fix memory leak in dw_i3c_master_i3c_xfers() Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®