From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Xiaolei Wang <xiaolei.wang@windriver.com>
Cc: mchehab@kernel.org, Frank.li@nxp.com, 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 v2 2/4] media: imx8-isi: add missing v4l2_subdev_cleanup() in crossbar and pipe
Date: Wed, 6 May 2026 15:35:41 +0300 [thread overview]
Message-ID: <20260506123541.GO1598374@killaraus.ideasonboard.com> (raw)
In-Reply-To: <20260506031210.2769998-3-xiaolei.wang@windriver.com>
Hello Xiaolei,
Thank you for the patch.
On Wed, May 06, 2026 at 11:12:08AM +0800, Xiaolei Wang wrote:
> Both mxc_isi_crossbar_init() and mxc_isi_pipe_init() call
> v4l2_subdev_init_finalize() which allocates the subdev active state,
> but neither mxc_isi_crossbar_cleanup() nor mxc_isi_pipe_cleanup()
> calls v4l2_subdev_cleanup() to free it.
>
> This causes a memory leak on every rmmod, reported by kmemleak:
>
> unreferenced object 0xffff0000d06fc800 (size 192):
> comm "(udev-worker)", pid 254, jiffies 4294913455
> backtrace (crc 36eeae58):
> kmemleak_alloc+0x34/0x40
> __kvmalloc_node_noprof+0x5f8/0x7d8
> __v4l2_subdev_state_alloc+0x1fc/0x30c
> __v4l2_subdev_init_finalize+0x178/0x368
>
> Add the missing v4l2_subdev_cleanup() calls before media_entity_cleanup()
> in both crossbar and pipe cleanup paths.
>
> Fixes: cf21f328fcaf ("media: nxp: Add i.MX8 ISI driver")
> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---
> drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c | 1 +
> drivers/media/platform/nxp/imx8-isi/imx8-isi-pipe.c | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
> index 605a45124103..c580c831972e 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
> @@ -491,6 +491,7 @@ int mxc_isi_crossbar_init(struct mxc_isi_dev *isi)
>
> void mxc_isi_crossbar_cleanup(struct mxc_isi_crossbar *xbar)
> {
> + v4l2_subdev_cleanup(&xbar->sd);
> media_entity_cleanup(&xbar->sd.entity);
> kfree(xbar->pads);
> kfree(xbar->inputs);
> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-pipe.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-pipe.c
> index a41c51dd9ce0..cb50af2270f6 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-pipe.c
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-pipe.c
> @@ -819,6 +819,7 @@ void mxc_isi_pipe_cleanup(struct mxc_isi_pipe *pipe)
> {
> struct v4l2_subdev *sd = &pipe->sd;
>
> + v4l2_subdev_cleanup(sd);
v4l2_subdev_cleanup() should also be called in some of the error paths
of mxc_isi_pipe_init(). This can be done in a separate patch, so
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> media_entity_cleanup(&sd->entity);
> mutex_destroy(&pipe->lock);
> }
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2026-05-06 12:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 3:12 [PATCH v2 0/4] media: imx8-isi: fix resource cleanup issues Xiaolei Wang
2026-05-06 3:12 ` [PATCH v2 1/4] media: imx8-isi: fix use-after-free on remove Xiaolei Wang
2026-05-06 12:31 ` Laurent Pinchart
2026-05-06 3:12 ` [PATCH v2 2/4] media: imx8-isi: add missing v4l2_subdev_cleanup() in crossbar and pipe Xiaolei Wang
2026-05-06 12:35 ` Laurent Pinchart [this message]
2026-05-06 14:23 ` xiaolei wang
2026-05-06 3:12 ` [PATCH v2 3/4] media: imx8-isi: fix isi->pipes memory leak in probe and remove Xiaolei Wang
2026-05-06 12:41 ` Laurent Pinchart
2026-05-06 14:29 ` xiaolei wang
2026-05-06 3:12 ` [PATCH v2 4/4] media: imx8-isi: clean up already-initialized pipes on probe failure Xiaolei Wang
2026-05-06 14:19 ` Laurent Pinchart
2026-05-06 14:25 ` 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=20260506123541.GO1598374@killaraus.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.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=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 \
--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