Skip to content

Commit 2cf0171

Browse files
moonlinuxgregkh
authored andcommitted
media: meson: vdec: Fix memory leak in error path of vdec_open
commit 940f161 upstream. The vdec_open() function previously jumped directly to err_m2m_release when vdec_init_ctrls() failed, skipping release of the m2m context. This caused a resource leak. Fix it by introducing a proper err_m2m_ctx_release label that calls v4l2_m2m_ctx_release(sess->m2m_ctx) before releasing the m2m device. This was identified via kmemleak: unreferenced object 0xffff0000205d6878 (size 8): comm "v4l_id", pid 5289, jiffies 4294938580 hex dump (first 8 bytes): 40 d2 49 18 00 00 ff ff @.I..... backtrace (crc d3204599): kmemleak_alloc+0xc8/0xf0 __kvmalloc_node_noprof+0x60c/0x850 v4l2_ctrl_handler_init_class+0x1b4/0x2e8 [videodev] vdec_open+0x1f4/0x788 [meson_vdec] v4l2_open+0x144/0x460 [videodev] chrdev_open+0x1ac/0x500 do_dentry_open+0x3f0/0xfe8 vfs_open+0x68/0x320 do_open+0x2d8/0x9a8 path_openat+0x1d0/0x4f0 do_filp_open+0x190/0x380 do_sys_openat2+0xf8/0x1b0 __arm64_sys_openat+0x13c/0x1e8 invoke_syscall+0xdc/0x268 el0_svc_common.constprop.0+0x178/0x258 do_el0_svc+0x4c/0x70 Fixes: 3e7f51b ("media: meson: add v4l2 m2m video decoder driver") Cc: stable@vger.kernel.org Signed-off-by: Anand Moon <linux.amoon@gmail.com> Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c1e2552 commit 2cf0171

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • drivers/staging/media/meson/vdec

drivers/staging/media/meson/vdec/vdec.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ static int vdec_open(struct file *file)
898898

899899
ret = vdec_init_ctrls(sess);
900900
if (ret)
901-
goto err_m2m_release;
901+
goto err_m2m_ctx_release;
902902

903903
sess->pixfmt_cap = formats[0].pixfmts_cap[0];
904904
sess->fmt_out = &formats[0];
@@ -923,6 +923,8 @@ static int vdec_open(struct file *file)
923923

924924
return 0;
925925

926+
err_m2m_ctx_release:
927+
v4l2_m2m_ctx_release(sess->m2m_ctx);
926928
err_m2m_release:
927929
v4l2_m2m_release(sess->m2m_dev);
928930
err_free_sess:

0 commit comments

Comments
 (0)