Skip to contentSkip to conversation

iommu/arm-smmu-v3: Fix error check in arm_smmu_alloc_cd_tables

PATCH Applied Ryan Huang 5 participants 5 messages Nov 7, 2025 – Nov 24, 2025

Subsystems (2)
lore
Share & tools
lore

Ryan Huang

author
#0 lore raw

PATCH 1/1 iommu/arm-smmu-v3: Fix error check in arm_smmu_alloc_cd_tables

In arm_smmu_alloc_cd_tables(), the error check following the dma_alloc_coherent() for cd_table->l2.l1tab incorrectly tests cd_table->l2.l2ptrs.

This means an allocation failure for l1tab goes undetected, causing the function to return 0 (success) erroneously.

Correct the check to test cd_table->l2.l1tab.

Fixes e3b1be2e73db ("iommu/arm-smmu-v3: Reorganize struct arm_smmu_ctx_desc_cfg")
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +1 -1
index 2a8b46b948f0..9780f40ba3e6 100644
@@ -1464,7 +1464,7 @@ static int arm_smmu_alloc_cd_tables(struct arm_smmu_master *master)
 		cd_table->l2.l1tab = dma_alloc_coherent(smmu->dev, l1size,
 							&cd_table->cdtab_dma,
 							GFP_KERNEL);
-		if (!cd_table->l2.l2ptrs) {
+		if (!cd_table->l2.l1tab) {
 			ret = -ENOMEM;
 			goto err_free_l2ptrs;
 		}
Signature · 1 line
2.51.2.1041.gc1ab5b90ca-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Ryan Huang

In arm_smmu_alloc_cd_tables(), the error check following the dma_alloc_coherent() for cd_table->l2.l1tab incorrectly tests cd_table->l2.l2ptrs.

This means an allocation failure for l1tab goes undetected, causing the function to return 0 (success) erroneously.

Quoted 8 lines

Correct the check to test cd_table->l2.l1tab.

Fixes e3b1be2e73db ("iommu/arm-smmu-v3: Reorganize struct arm_smmu_ctx_desc_cfg")
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Jason

Reviewed-by on v1 1/1
#2 lore raw
In reply to Ryan Huang
Quoted 7 lines · Ryan Huang

In arm_smmu_alloc_cd_tables(), the error check following the dma_alloc_coherent() for cd_table->l2.l1tab incorrectly tests cd_table->l2.l2ptrs.

This means an allocation failure for l1tab goes undetected, causing the function to return 0 (success) erroneously.

Quoted 9 lines

Correct the check to test cd_table->l2.l1tab.

Fixes e3b1be2e73db ("iommu/arm-smmu-v3: Reorganize struct arm_smmu_ctx_desc_cfg")
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks for the fix!
-Praan

Reviewed-by on v1 1/1
#3 lore raw
In reply to Ryan Huang
Quoted 4 lines · Ryan Huang

In arm_smmu_alloc_cd_tables(), the error check following the dma_alloc_coherent() for cd_table->l2.l1tab incorrectly tests cd_table->l2.l2ptrs.

Quoted 8 lines

This means an allocation failure for l1tab goes undetected, causing the function to return 0 (success) erroneously.

Correct the check to test cd_table->l2.l1tab.

Fixes e3b1be2e73db ("iommu/arm-smmu-v3: Reorganize struct arm_smmu_ctx_desc_cfg")
maintainer Applied
#4 lore raw
In reply to Ryan Huang
Quoted 8 lines · Ryan Huang

In arm_smmu_alloc_cd_tables(), the error check following the dma_alloc_coherent() for cd_table->l2.l1tab incorrectly tests cd_table->l2.l2ptrs.

This means an allocation failure for l1tab goes undetected, causing the function to return 0 (success) erroneously.

[...]

Applied to iommu (arm/smmu/updates), thanks!

[1/1] iommu/arm-smmu-v3: Fix error check in arm_smmu_alloc_cd_tables

      https://git.kernel.org/iommu/c/5941f0e0c1e0

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev