media: meson: vdec: fix possible refcount leak in vdec_probe()
authorHangyu Hua <hbh25y@gmail.com>
Tue, 6 Sep 2022 07:46:30 +0000 (09:46 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sat, 24 Sep 2022 06:55:43 +0000 (08:55 +0200)
v4l2_device_unregister need to be called to put the refcount got by
v4l2_device_register when vdec_probe fails or vdec_remove is called.

Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/staging/media/meson/vdec/vdec.c

index 8549d95be0f25cbb07d9b5a8162a5acdb28fbcc1..52f224d8def10425ecb947a8fa99cd4672735c6b 100644 (file)
@@ -1102,6 +1102,7 @@ static int vdec_probe(struct platform_device *pdev)
 
 err_vdev_release:
        video_device_release(vdev);
+       v4l2_device_unregister(&core->v4l2_dev);
        return ret;
 }
 
@@ -1110,6 +1111,7 @@ static int vdec_remove(struct platform_device *pdev)
        struct amvdec_core *core = platform_get_drvdata(pdev);
 
        video_unregister_device(core->vdev_dec);
+       v4l2_device_unregister(&core->v4l2_dev);
 
        return 0;
 }