From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Xiaolei Wang <xiaolei.wang@windriver.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"Frank.Li@nxp.com" <Frank.Li@nxp.com>,
"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>,
"kernel@pengutronix.de" <kernel@pengutronix.de>,
"festevam@gmail.com" <festevam@gmail.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"imx@lists.linux.dev" <imx@lists.linux.dev>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] usb: dwc3: imx8mp: fix memory leak on probe failure path
Date: Wed, 1 Apr 2026 22:55:05 +0000 [thread overview]
Message-ID: <20260401225502.24r6375pfzq4x3d2@synopsys.com> (raw)
In-Reply-To: <20260401134938.686748-1-xiaolei.wang@windriver.com>
On Wed, Apr 01, 2026, Xiaolei Wang wrote:
> When platform_get_drvdata() returns NULL and probe defers, the error
> path jumps to the 'depopulate' label, skipping put_device() for the
> reference acquired by of_find_device_by_node(). This extra reference
> prevents the child platform device from being freed when
> of_platform_depopulate() is called, resulting in memory leaks reported
> by kmemleak:
>
> unreferenced object 0xffff0000c92c1480 (size 64):
> comm "kworker/u16:2", pid 50, jiffies 4294895789
> backtrace (crc 49d507d0):
> kmemleak_alloc+0x34/0x40
> __kmalloc_noprof+0x430/0x670
> of_device_alloc+0xec/0x26c
> of_platform_device_create_pdata+0x60/0x1f0
> of_platform_bus_create+0x290/0x610
> of_platform_populate+0x74/0x118
> dwc3_imx8mp_probe+0x228/0x734
>
> Fixes: 86767625f525 ("usb: dwc3: imx8mp: disable auto suspend for host role")
> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
> ---
> drivers/usb/dwc3/dwc3-imx8mp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
> index b3d7252bd910..1cf96540b66e 100644
> --- a/drivers/usb/dwc3/dwc3-imx8mp.c
> +++ b/drivers/usb/dwc3/dwc3-imx8mp.c
> @@ -263,7 +263,7 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
> dwc3 = platform_get_drvdata(dwc3_imx->dwc3_pdev);
> if (!dwc3) {
> err = dev_err_probe(dev, -EPROBE_DEFER, "failed to get dwc3 platform data\n");
> - goto depopulate;
> + goto put_dwc3;
> }
>
> dwc3->glue_ops = &dwc3_imx_glue_ops;
> --
> 2.43.0
>
Thanks for the catch.
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Thanks,
Thinh
prev parent reply other threads:[~2026-04-01 22:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-01 13:49 [PATCH] usb: dwc3: imx8mp: fix memory leak on probe failure path Xiaolei Wang
2026-04-01 22:55 ` Thinh Nguyen [this message]
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=20260401225502.24r6375pfzq4x3d2@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=Frank.Li@nxp.com \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=xiaolei.wang@windriver.com \
/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