]> git.baikalelectronics.ru Git - kernel.git/commitdiff
media: rga: fix possible memory leak in rga_probe
authorHangyu Hua <hbh25y@gmail.com>
Thu, 24 Mar 2022 08:37:24 +0000 (09:37 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 13 May 2022 09:02:19 +0000 (11:02 +0200)
rga->m2m_dev needs to be freed when rga_probe fails.

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/rockchip/rga/rga.c

index 3d3d1062e2122b49d166c3fe7e3b045ff370e740..2f8df74ad0fdec71e5372349007a31a9fa369df0 100644 (file)
@@ -865,7 +865,7 @@ static int rga_probe(struct platform_device *pdev)
 
        ret = pm_runtime_resume_and_get(rga->dev);
        if (ret < 0)
-               goto rel_vdev;
+               goto rel_m2m;
 
        rga->version.major = (rga_read(rga, RGA_VERSION_INFO) >> 24) & 0xFF;
        rga->version.minor = (rga_read(rga, RGA_VERSION_INFO) >> 20) & 0x0F;
@@ -881,7 +881,7 @@ static int rga_probe(struct platform_device *pdev)
                                           DMA_ATTR_WRITE_COMBINE);
        if (!rga->cmdbuf_virt) {
                ret = -ENOMEM;
-               goto rel_vdev;
+               goto rel_m2m;
        }
 
        rga->src_mmu_pages =
@@ -918,6 +918,8 @@ free_src_pages:
 free_dma:
        dma_free_attrs(rga->dev, RGA_CMDBUF_SIZE, rga->cmdbuf_virt,
                       rga->cmdbuf_phy, DMA_ATTR_WRITE_COMBINE);
+rel_m2m:
+       v4l2_m2m_release(rga->m2m_dev);
 rel_vdev:
        video_device_release(vfd);
 unreg_v4l2_dev: