From: Frank Li <Frank.li@nxp.com>
To: Zilin Guan <zilin@seu.edu.cn>
Cc: alexandre.belloni@bootlin.com, aniketmaurya@google.com,
linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org,
jianhao.xu@seu.edu.cn
Subject: Re: [PATCH] i3c: dw: Fix memory leak in dw_i3c_master_i2c_xfers()
Date: Mon, 26 Jan 2026 12:01:31 -0500 [thread overview]
Message-ID: <aXed6/fa3bCJhxPF@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20260126081121.644099-1-zilin@seu.edu.cn>
On Mon, Jan 26, 2026 at 08:11:21AM +0000, Zilin Guan wrote:
> 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>
After https://lore.kernel.org/linux-i3c/176840902682.1305594.13987931108275156748.b4-ty@bootlin.com/T/#t
driver's runtime pm get code can be removed.
Frank
> 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 889e2ed5bc83..3e6f66dff2ec 100644
> --- a/drivers/i3c/master/dw-i3c-master.c
> +++ b/drivers/i3c/master/dw-i3c-master.c
> @@ -1099,6 +1099,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;
> }
>
> --
> 2.34.1
>
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
next prev parent reply other threads:[~2026-01-26 17:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-26 8:11 [PATCH] i3c: dw: Fix memory leak in dw_i3c_master_i2c_xfers() Zilin Guan
2026-01-26 10:22 ` Markus Elfring
2026-01-26 17:01 ` Frank Li [this message]
2026-01-30 23:08 ` Alexandre Belloni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aXed6/fa3bCJhxPF@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=alexandre.belloni@bootlin.com \
--cc=aniketmaurya@google.com \
--cc=jianhao.xu@seu.edu.cn \
--cc=linux-i3c@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zilin@seu.edu.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox