]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: nxp: imx8-isi: Add missing v4l2_subdev_cleanup() in crossbar and pipe
authorXiaolei Wang <xiaolei.wang@windriver.com>
Thu, 7 May 2026 04:13:16 +0000 (12:13 +0800)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Thu, 21 May 2026 05:41:32 +0000 (07:41 +0200)
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")
Cc: stable@vger.kernel.org
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://patch.msgid.link/20260507041318.491594-3-xiaolei.wang@windriver.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
drivers/media/platform/nxp/imx8-isi/imx8-isi-pipe.c

index 605a451241035c93b1d6f6ab2aac61c5dbfe4618..c580c831972ec303e25177d93d754d5820958453 100644 (file)
@@ -491,6 +491,7 @@ err_free:
 
 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);
index a41c51dd9ce0f2eeb779e9aa2461593b0d635f41..cb50af2270f6cf4f5c3d39931593b7980280dd77 100644 (file)
@@ -819,6 +819,7 @@ void mxc_isi_pipe_cleanup(struct mxc_isi_pipe *pipe)
 {
        struct v4l2_subdev *sd = &pipe->sd;
 
+       v4l2_subdev_cleanup(sd);
        media_entity_cleanup(&sd->entity);
        mutex_destroy(&pipe->lock);
 }