media: rkvdec: Fix an error handling path in rkvdec_probe()

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: ff8c5622f9 ("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>
This commit is contained in:
Christophe JAILLET 2025-07-30 20:24:44 +02:00 committed by Hans Verkuil
parent 6347dc7fb9
commit 0d58a72b66

View 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: