* [PATCH v2] media: rkvdec: Fix an error handling path in rkvdec_probe()
@ 2025-07-30 18:24 Christophe JAILLET
2025-08-11 14:27 ` Nicolas Dufresne
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2025-07-30 18:24 UTC (permalink / raw)
To: Detlev Casanova, Mauro Carvalho Chehab, Heiko Stuebner,
Hans Verkuil, Nicolas Dufresne
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-media,
linux-rockchip, linux-arm-kernel
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>
---
Compile tested only.
Changes in v2:
- Move code instead of handling errors [Nicolas Dufresne]
- Add R-b tag
v1: https://lore.kernel.org/all/b69c20783a7b6f7964ab636679d3da80fc48372e.1753610517.git.christophe.jaillet@wanadoo.fr/
---
drivers/media/platform/rockchip/rkvdec/rkvdec.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
index d707088ec0dc..6eae10e16c73 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
@@ -1159,13 +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 (!rkvdec->empty_domain)
- 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);
@@ -1188,6 +1181,13 @@ 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 (!rkvdec->empty_domain)
+ dev_warn(rkvdec->dev, "cannot alloc new empty domain\n");
+ }
+
return 0;
err_disable_runtime_pm:
--
2.50.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] media: rkvdec: Fix an error handling path in rkvdec_probe()
2025-07-30 18:24 [PATCH v2] media: rkvdec: Fix an error handling path in rkvdec_probe() Christophe JAILLET
@ 2025-08-11 14:27 ` Nicolas Dufresne
0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Dufresne @ 2025-08-11 14:27 UTC (permalink / raw)
To: Christophe JAILLET, Detlev Casanova, Mauro Carvalho Chehab,
Heiko Stuebner, Hans Verkuil
Cc: linux-kernel, kernel-janitors, linux-media, linux-rockchip,
linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 2341 bytes --]
Hi,
Le mercredi 30 juillet 2025 à 20:24 +0200, Christophe JAILLET a écrit :
> 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>
> ---
> Compile tested only.
>
> Changes in v2:
> - Move code instead of handling errors [Nicolas Dufresne]
> - Add R-b tag
>
> v1:
> https://lore.kernel.org/all/b69c20783a7b6f7964ab636679d3da80fc48372e.1753610517.git.christophe.jaillet@wanadoo.fr/
> ---
> drivers/media/platform/rockchip/rkvdec/rkvdec.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c
> b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
> index d707088ec0dc..6eae10e16c73 100644
> --- a/drivers/media/platform/rockchip/rkvdec/rkvdec.c
> +++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
> @@ -1159,13 +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 (!rkvdec->empty_domain)
> - dev_warn(rkvdec->dev, "cannot alloc new empty
> domain\n");
> - }
I've re-applied including Dan's fixes, iommu_paging_domain_alloc() does not
return NULL on error. No action required.
Nicolas
> -
> vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32));
>
> irq = platform_get_irq(pdev, 0);
> @@ -1188,6 +1181,13 @@ 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 (!rkvdec->empty_domain)
> + dev_warn(rkvdec->dev, "cannot alloc new empty
> domain\n");
> + }
> +
> return 0;
>
> err_disable_runtime_pm:
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-11 16:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-30 18:24 [PATCH v2] media: rkvdec: Fix an error handling path in rkvdec_probe() Christophe JAILLET
2025-08-11 14:27 ` Nicolas Dufresne
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).