drivers/media/platform/rockchip/rkvdec/rkvdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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
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
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"); > } >
© 2016 - 2025 Red Hat, Inc.