Commit 0d58a72b authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Hans Verkuil
Browse files

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: ff8c5622 ("media: rkvdec: Restore iommu addresses on errors")
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: default avatarNicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: default avatarNicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil+cisco@kernel.org>
parent 6347dc7f
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -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: