From: xiaolei wang <xiaolei.wang@windriver.com>
To: Frank Li <Frank.li@nxp.com>
Cc: laurent.pinchart@ideasonboard.com, mchehab@kernel.org,
s.hauer@pengutronix.de, kernel@pengutronix.de,
festevam@gmail.com, aisheng.dong@nxp.com, jacopo@jmondi.org,
guoniu.zhou@nxp.com, s.riedmueller@phytec.de,
linux-media@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 3/3] media: imx8-isi: fix resource leaks in probe error paths and remove
Date: Tue, 5 May 2026 10:39:16 +0800 [thread overview]
Message-ID: <1bbd7824-a15d-47c6-baf7-03841bff5439@windriver.com> (raw)
In-Reply-To: <afjHnSEYm4t0rko8@lizhi-Precision-Tower-5810>
Hi Frank
Thank you for your review
On 5/5/26 00:21, Frank Li wrote:
> CAUTION: This email comes from a non Wind River email account!
> Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
> On Sat, Apr 25, 2026 at 07:19:26AM +0800, Xiaolei Wang wrote:
>> mxc_isi_probe() allocates isi->pipes with kzalloc_objs() but never
>> frees it on any probe failure path or in mxc_isi_remove(), leaking
>> the allocation on every failed probe and every normal unbind.
>>
>> Additionally, when mxc_isi_pipe_init() fails partway through the
>> channel loop or when mxc_isi_v4l2_init() fails, the already
>> initialized pipes are not cleaned up — their media entities and
>> mutexes are leaked.
> Although it simple change, it is two problems, suggest use two patches to
> fix it.
Yes, it's two issues, and I will use two patches in the next version.
thanks
xiaolei
>
> Frank
>> Fix the pipes memory leak by switching from kzalloc_objs() to
>> devm_kcalloc(), which ties the allocation lifetime to the device
>> and eliminates the need for explicit kfree() in all error paths
>> and in mxc_isi_remove().
>>
>> Fix the pipe init leak by cleaning up already-initialized pipes
>> in the err_xbar error path.
>>
>> Fixes: cf21f328fcaf ("media: nxp: Add i.MX8 ISI driver")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
>> ---
>> drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
>> index 2d639b789910..8533a979d60a 100644
>> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
>> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
>> @@ -485,7 +485,8 @@ static int mxc_isi_probe(struct platform_device *pdev)
>>
>> isi->pdata = of_device_get_match_data(dev);
>>
>> - isi->pipes = kzalloc_objs(isi->pipes[0], isi->pdata->num_channels);
>> + isi->pipes = devm_kcalloc(dev, isi->pdata->num_channels,
>> + sizeof(*isi->pipes), GFP_KERNEL);
>> if (!isi->pipes)
>> return -ENOMEM;
>>
>> @@ -538,6 +539,8 @@ static int mxc_isi_probe(struct platform_device *pdev)
>> return 0;
>>
>> err_xbar:
>> + while (i--)
>> + mxc_isi_pipe_cleanup(&isi->pipes[i]);
>> mxc_isi_crossbar_cleanup(&isi->crossbar);
>>
>> return ret;
>> --
>> 2.43.0
>>
prev parent reply other threads:[~2026-05-05 2:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-24 23:19 [PATCH 0/3] media: imx8-isi: fix resource lifecycle bugs Xiaolei Wang
2026-04-24 23:19 ` [PATCH 1/3] media: imx8-isi: fix use-after-free on remove Xiaolei Wang
2026-05-04 16:19 ` Frank Li
2026-04-24 23:19 ` [PATCH 2/3] media: imx8-isi: add missing v4l2_subdev_cleanup() in crossbar and pipe Xiaolei Wang
2026-05-04 16:22 ` Frank Li
2026-04-24 23:19 ` [PATCH 3/3] media: imx8-isi: fix resource leaks in probe error paths and remove Xiaolei Wang
2026-05-04 16:21 ` Frank Li
2026-05-05 2:39 ` xiaolei wang [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=1bbd7824-a15d-47c6-baf7-03841bff5439@windriver.com \
--to=xiaolei.wang@windriver.com \
--cc=Frank.li@nxp.com \
--cc=aisheng.dong@nxp.com \
--cc=festevam@gmail.com \
--cc=guoniu.zhou@nxp.com \
--cc=imx@lists.linux.dev \
--cc=jacopo@jmondi.org \
--cc=kernel@pengutronix.de \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=s.riedmueller@phytec.de \
--cc=stable@vger.kernel.org \
/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