Skip to content

Commit d7665c3

Browse files
outman119alexandrebelloni
authored andcommitted
i3c: master: renesas: Fix memory leak in renesas_i3c_i3c_xfers()
The xfer structure allocated by renesas_i3c_alloc_xfer() was never freed in the renesas_i3c_i3c_xfers() function. Use the __free(kfree) cleanup attribute to automatically free the memory when the variable goes out of scope. Fixes: d028219 ("i3c: master: Add basic driver for the Renesas I3C controller") Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com> Reviewed-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Felix Gu <ustc.gu@gmail.com> Link: https://patch.msgid.link/20260406-renesas-v3-1-4b724d7708f4@gmail.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
1 parent 19d6dd3 commit d7665c3

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/i3c/master/renesas-i3c.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <linux/bitfield.h>
1010
#include <linux/bitops.h>
11+
#include <linux/cleanup.h>
1112
#include <linux/clk.h>
1213
#include <linux/completion.h>
1314
#include <linux/err.h>
@@ -817,13 +818,12 @@ static int renesas_i3c_i3c_xfers(struct i3c_dev_desc *dev, struct i3c_xfer *i3c_
817818
struct i3c_master_controller *m = i3c_dev_get_master(dev);
818819
struct renesas_i3c *i3c = to_renesas_i3c(m);
819820
struct renesas_i3c_i2c_dev_data *data = i3c_dev_get_master_data(dev);
820-
struct renesas_i3c_xfer *xfer;
821821
int i;
822822

823823
/* Enable I3C bus. */
824824
renesas_i3c_bus_enable(m, true);
825825

826-
xfer = renesas_i3c_alloc_xfer(i3c, 1);
826+
struct renesas_i3c_xfer *xfer __free(kfree) = renesas_i3c_alloc_xfer(i3c, 1);
827827
if (!xfer)
828828
return -ENOMEM;
829829

0 commit comments

Comments
 (0)