linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: rkvdec: Fix incorrect NULL check for iommu_paging_domain_alloc
@ 2025-08-05  6:18 Miaoqian Lin
  2025-08-05  8:40 ` Heiko Stübner
  2025-08-05 12:05 ` Nicolas Dufresne
  0 siblings, 2 replies; 3+ messages in thread
From: Miaoqian Lin @ 2025-08-05  6:18 UTC (permalink / raw)
  To: Detlev Casanova, Mauro Carvalho Chehab, Heiko Stuebner,
	Nicolas Dufresne, Hans Verkuil, linux-media, linux-rockchip,
	linux-arm-kernel, linux-kernel
  Cc: linmq006

iommu_paging_domain_alloc returns error pointers on failure.
Replace the NULL check with IS_ERR to correctly handle error cases
and avoid invalid pointer dereference.

Fixes: ff8c5622f9f7 ("media: rkvdec: Restore iommu addresses on errors")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/media/platform/rockchip/rkvdec/rkvdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
index d707088ec0dc..1d40e81f44b9 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
@@ -1162,7 +1162,7 @@ static int rkvdec_probe(struct platform_device *pdev)
 	if (iommu_get_domain_for_dev(&pdev->dev)) {
 		rkvdec->empty_domain = iommu_paging_domain_alloc(rkvdec->dev);
 
-		if (!rkvdec->empty_domain)
+		if (IS_ERR(rkvdec->empty_domain))
 			dev_warn(rkvdec->dev, "cannot alloc new empty domain\n");
 	}
 
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: rkvdec: Fix incorrect NULL check for iommu_paging_domain_alloc
  2025-08-05  6:18 [PATCH] media: rkvdec: Fix incorrect NULL check for iommu_paging_domain_alloc Miaoqian Lin
@ 2025-08-05  8:40 ` Heiko Stübner
  2025-08-05 12:05 ` Nicolas Dufresne
  1 sibling, 0 replies; 3+ messages in thread
From: Heiko Stübner @ 2025-08-05  8:40 UTC (permalink / raw)
  To: Detlev Casanova, Mauro Carvalho Chehab, Nicolas Dufresne,
	Hans Verkuil, linux-media, linux-rockchip, linux-arm-kernel,
	linux-kernel, Miaoqian Lin
  Cc: linmq006

Am Dienstag, 5. August 2025, 08:18:33 Mitteleuropäische Sommerzeit schrieb Miaoqian Lin:
> iommu_paging_domain_alloc returns error pointers on failure.
> Replace the NULL check with IS_ERR to correctly handle error cases
> and avoid invalid pointer dereference.
> 
> Fixes: ff8c5622f9f7 ("media: rkvdec: Restore iommu addresses on errors")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>

Going from the (static inline) function definition [0] to the
iommu_paging_domain_alloc_flags() function [1] it uses, the doc states
	"Return [...]  or an ERR pointer for failure."

So this is the correct fix,
Reviewed-by: Heiko Stuebner <heiko@sntech.de>



[0] https://elixir.bootlin.com/linux/v6.16/source/include/linux/iommu.h#L858
[1] https://elixir.bootlin.com/linux/v6.16/source/drivers/iommu/iommu.c#L2046




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: rkvdec: Fix incorrect NULL check for iommu_paging_domain_alloc
  2025-08-05  6:18 [PATCH] media: rkvdec: Fix incorrect NULL check for iommu_paging_domain_alloc Miaoqian Lin
  2025-08-05  8:40 ` Heiko Stübner
@ 2025-08-05 12:05 ` Nicolas Dufresne
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Dufresne @ 2025-08-05 12:05 UTC (permalink / raw)
  To: Miaoqian Lin, Detlev Casanova, Mauro Carvalho Chehab,
	Heiko Stuebner, Hans Verkuil, linux-media, linux-rockchip,
	linux-arm-kernel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1356 bytes --]

Hi,

Le mardi 05 août 2025 à 10:18 +0400, Miaoqian Lin a écrit :
> iommu_paging_domain_alloc returns error pointers on failure.
> Replace the NULL check with IS_ERR to correctly handle error cases
> and avoid invalid pointer dereference.
> 
> Fixes: ff8c5622f9f7 ("media: rkvdec: Restore iommu addresses on errors")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
>  drivers/media/platform/rockchip/rkvdec/rkvdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c
> b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
> index d707088ec0dc..1d40e81f44b9 100644
> --- a/drivers/media/platform/rockchip/rkvdec/rkvdec.c
> +++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
> @@ -1162,7 +1162,7 @@ static int rkvdec_probe(struct platform_device *pdev)
>  	if (iommu_get_domain_for_dev(&pdev->dev)) {
>  		rkvdec->empty_domain = iommu_paging_domain_alloc(rkvdec-
> >dev);
>  
> -		if (!rkvdec->empty_domain)
> +		if (IS_ERR(rkvdec->empty_domain))


Thanks for the fix, but Dan Carpenter have already sent this fix. It will be
included soon.

https://lore.kernel.org/linux-media/696219e9-a1c7-4c87-b15c-1ffd42c95d58@sabinyo.mountain/

regards,
Nicolas

>  			dev_warn(rkvdec->dev, "cannot alloc new empty
> domain\n");
>  	}
>  

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-05 12:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-05  6:18 [PATCH] media: rkvdec: Fix incorrect NULL check for iommu_paging_domain_alloc Miaoqian Lin
2025-08-05  8:40 ` Heiko Stübner
2025-08-05 12:05 ` 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).