]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
i3c: dw: Fix memory leak in dw_i3c_master_i2c_xfers()
authorZilin Guan <zilin@seu.edu.cn>
Mon, 26 Jan 2026 08:11:21 +0000 (08:11 +0000)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Fri, 30 Jan 2026 23:03:46 +0000 (00:03 +0100)
The dw_i3c_master_i2c_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.

Add a dw_i3c_master_free_xfer() call to the error path to ensure the
allocated memory is properly freed.

Compile tested only. Issue found using a prototype static analysis tool
and code review.

Fixes: 62fe9d06f570 ("i3c: dw: Add power management support")
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260126081121.644099-1-zilin@seu.edu.cn
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/i3c/master/dw-i3c-master.c

index e9b2c23ed1715f81084a68c07fd783c898c7f734..cfc15aaf8c7bb2ed2337180cb83e68d444b88209 100644 (file)
@@ -1106,6 +1106,7 @@ 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;
        }