media: rkvdec: Fix incorrect NULL check for iommu_paging_domain_alloc
Subsystems (3)
PATCH 1/1 media: rkvdec: Fix incorrect NULL check for iommu_paging_domain_alloc
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.
--- drivers/media/platform/rockchip/rkvdec/rkvdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/rockchip/rkvdec/rkvdec.c +1 -1
@@ -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" ); }
Signature · 1 line
2.35.1
Am Dienstag, 5. August 2025, 08:18:33 Mitteleuropäische Sommerzeit schrieb Miaoqian Lin:
Quoted 6 lines
iommu_paging_domain_allocreturns error pointers on failure. Replace the NULL check withIS_ERRto correctly handle error cases and avoid invalid pointer dereference.Fixes ff8c5622f9f7 ("media: rkvdec: Restore iommu addresses on errors")Signed-off-by Miaoqian Lin <[email protected]>
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,
[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 :
Quoted 20 lines
iommu_paging_domain_allocreturns error pointers on failure. Replace the NULL check withIS_ERRto correctly handle error cases and avoid invalid pointer dereference.Fixes ff8c5622f9f7 ("media: rkvdec: Restore iommu addresses on errors")Signed-off-by Miaoqian Lin <[email protected]>---
drivers/media/platform/rockchip/rkvdec/rkvdec.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/rockchip/rkvdec/rkvdec.c +0
-0@@ -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-Quoted 1 line
dev);
drivers/media/platform/rockchip/rkvdec/rkvdec.c static int rkvdec_probe(struct platform_device *pdev) · line 1165
Quoted 2 lines
drivers/media/platform/rockchip/rkvdec/rkvdec.c +1
-1-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/[email protected]/
regards,
Nicolas
Quoted 4 lines
dev_warn(rkvdec->dev, "cannot alloc new empty domain\n");
}