media: platform: fix some double free in meson-ge2d and mtk-jpeg and s5p-mfc
authorHangyu Hua <hbh25y@gmail.com>
Tue, 16 Aug 2022 08:58:19 +0000 (10:58 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Tue, 30 Aug 2022 13:20:49 +0000 (15:20 +0200)
video_unregister_device will release device internally. There is no need to
call video_device_release after video_unregister_device.

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/media/platform/amlogic/meson-ge2d/ge2d.c
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c

index 5e7b319..142d421 100644 (file)
@@ -1030,7 +1030,6 @@ static int ge2d_remove(struct platform_device *pdev)
 
        video_unregister_device(ge2d->vfd);
        v4l2_m2m_release(ge2d->m2m_dev);
-       video_device_release(ge2d->vfd);
        v4l2_device_unregister(&ge2d->v4l2_dev);
        clk_disable_unprepare(ge2d->clk);
 
index 87685a6..3071b61 100644 (file)
@@ -1414,7 +1414,6 @@ static int mtk_jpeg_remove(struct platform_device *pdev)
 
        pm_runtime_disable(&pdev->dev);
        video_unregister_device(jpeg->vdev);
-       video_device_release(jpeg->vdev);
        v4l2_m2m_release(jpeg->m2m_dev);
        v4l2_device_unregister(&jpeg->v4l2_dev);
 
index 219fc02..fca5c64 100644 (file)
@@ -1399,6 +1399,7 @@ static int s5p_mfc_probe(struct platform_device *pdev)
 /* Deinit MFC if probe had failed */
 err_enc_reg:
        video_unregister_device(dev->vfd_dec);
+       dev->vfd_dec = NULL;
 err_dec_reg:
        video_device_release(dev->vfd_enc);
 err_enc_alloc:
@@ -1444,8 +1445,6 @@ static int s5p_mfc_remove(struct platform_device *pdev)
 
        video_unregister_device(dev->vfd_enc);
        video_unregister_device(dev->vfd_dec);
-       video_device_release(dev->vfd_enc);
-       video_device_release(dev->vfd_dec);
        v4l2_device_unregister(&dev->v4l2_dev);
        s5p_mfc_unconfigure_dma_memory(dev);