[PATCH] i3c: dw: Fix memory leak in dw_i3c_master_i3c_xfers()

Felix Gu ustc.gu at gmail.com
Thu Apr 2 05:38:03 PDT 2026


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.

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

Fixes: 62fe9d06f570 ("i3c: dw: Add power management support")
Signed-off-by: Felix Gu <ustc.gu at gmail.com>
---
 drivers/i3c/master/dw-i3c-master.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
index d6bdb32397fb..d933db076c61 100644
--- a/drivers/i3c/master/dw-i3c-master.c
+++ b/drivers/i3c/master/dw-i3c-master.c
@@ -953,6 +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);
+		dw_i3c_master_free_xfer(xfer);
 		return ret;
 	}
 

---
base-commit: bd0f139e5fc11182777b81cefc3893ea508544ec
change-id: 20260402-dw-i3c-2-8f123def99b2

Best regards,
-- 
Felix Gu <ustc.gu at gmail.com>




More information about the linux-i3c mailing list