]> www.infradead.org Git - users/griffoul/linux.git/commitdiff
media: rkvdec: Fix an error handling path in rkvdec_probe()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Wed, 30 Jul 2025 18:24:44 +0000 (20:24 +0200)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Mon, 18 Aug 2025 07:55:05 +0000 (09:55 +0200)
If an error occurs after a successful iommu_paging_domain_alloc() call, it
should be undone by a corresponding iommu_domain_free() call, as already
done in the remove function.

In order to fix the issue, move the corresponding call at the end of the
function, because it is safe to allocate 'empty_domain' later.

Fixes: ff8c5622f9f7 ("media: rkvdec: Restore iommu addresses on errors")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/platform/rockchip/rkvdec/rkvdec.c

index 1b7f27e4d96116eceded29d567fb324ac00af96e..35265e321203612fbe2f71df3c58ab2f6be928ae 100644 (file)
@@ -1159,15 +1159,6 @@ static int rkvdec_probe(struct platform_device *pdev)
                return ret;
        }
 
-       if (iommu_get_domain_for_dev(&pdev->dev)) {
-               rkvdec->empty_domain = iommu_paging_domain_alloc(rkvdec->dev);
-
-               if (IS_ERR(rkvdec->empty_domain)) {
-                       rkvdec->empty_domain = NULL;
-                       dev_warn(rkvdec->dev, "cannot alloc new empty domain\n");
-               }
-       }
-
        vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32));
 
        irq = platform_get_irq(pdev, 0);
@@ -1190,6 +1181,15 @@ static int rkvdec_probe(struct platform_device *pdev)
        if (ret)
                goto err_disable_runtime_pm;
 
+       if (iommu_get_domain_for_dev(&pdev->dev)) {
+               rkvdec->empty_domain = iommu_paging_domain_alloc(rkvdec->dev);
+
+               if (IS_ERR(rkvdec->empty_domain)) {
+                       rkvdec->empty_domain = NULL;
+                       dev_warn(rkvdec->dev, "cannot alloc new empty domain\n");
+               }
+       }
+
        return 0;
 
 err_disable_runtime_pm: