From: sashiko-bot@kernel.org
To: "Laurent Pinchart" <laurent.pinchart@ideasonboard.com>
Cc: imx@lists.linux.dev, Frank.Li@kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH] media: nxp: imx8-isi: Fix small memory leak at unbind time
Date: Mon, 30 Nov 2026 02:28:50 +0000 [thread overview]
Message-ID: <sashiko-outbox-240246@kernel.org> (raw)
In-Reply-To: <20261130022322.22508-1-laurent.pinchart@ideasonboard.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] media: nxp: imx8-isi: missing pipe unregistration in
mxc_isi_v4l2_init() [1]
--
commit a31b14b46ef772648d300c8e857600dbf5ef7ce4
Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
media: nxp: imx8-isi: Fix small memory leak at unbind time
This commit switches the allocation of isi->pipes in mxc_isi_probe() from
kzalloc_objs() to devm_kzalloc_objs() so the array is freed on driver
unbind.
> 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 0ae5f35e017c6..9373a52562242 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
> @@ -488,7 +488,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_kzalloc_objs(dev, isi->pipes[0],
> + isi->pdata->num_channels);
> if (!isi->pipes)
> return -ENOMEM;
[Severity: High]
This problem wasn't introduced by this patch, but can a failure in
mxc_isi_v4l2_init() leak registered video devices and leave them
referencing devm-freed isi->pipes memory [1]?
drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c:mxc_isi_v4l2_init() {
...
for (i = 0; i < isi->pdata->num_channels; ++i) {
struct mxc_isi_pipe *pipe = &isi->pipes[i];
ret = mxc_isi_pipe_register(pipe);
if (ret < 0) {
dev_err(isi->dev, "Failed to register pipe%u: %d\n", i,
ret);
goto err_v4l2;
}
...
err_m2m:
mxc_isi_m2m_unregister(isi);
v4l2_async_nf_cleanup(&isi->notifier);
err_v4l2:
v4l2_device_unregister(v4l2_dev);
err_media:
media_device_cleanup(media_dev);
return ret;
}
mxc_isi_pipe_register() calls mxc_isi_video_register(), which registers a
capture video_device node and initializes V4L2 control handlers and media
entity pads. If a later step in mxc_isi_v4l2_init() fails, err_v4l2 only
calls v4l2_device_unregister(), which unregisters subdevs but does not
call mxc_isi_pipe_unregister() on the already-registered pipes. With
isi->pipes now managed by devm, probe failure frees the pipes array while
those /dev/videoN nodes remain registered, leading to a use-after-free if
userspace accesses them.
[1] https://sashiko.dev/#/bug/linux-aae9d84d-1755-4279-8a12-ff366e28c228
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130022322.22508-1-laurent.pinchart@ideasonboard.com?part=1
next prev parent reply other threads:[~2026-11-30 2:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 2:23 [PATCH] media: nxp: imx8-isi: Fix small memory leak at unbind time Laurent Pinchart
2026-11-30 2:28 ` sashiko-bot [this message]
2026-11-30 8:15 ` Paul Elder
2026-11-30 15:34 ` Frank Li
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=sashiko-outbox-240246@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=imx@lists.linux.dev \
--cc=laurent.pinchart@ideasonboard.com \
--cc=media-ci@linuxtv.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.