]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommu/arm-smmu-v3: Fix error check in arm_smmu_alloc_cd_tables
authorRyan Huang <tzukui@google.com>
Fri, 7 Nov 2025 19:09:17 +0000 (11:09 -0800)
committerWill Deacon <will@kernel.org>
Mon, 24 Nov 2025 16:56:31 +0000 (16:56 +0000)
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")
Signed-off-by: Daniel Mentz <danielmentz@google.com>
Signed-off-by: Ryan Huang <tzukui@google.com>
Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Will Deacon <will@kernel.org>
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

index 2a8b46b948f050e003e66424bee383c9ac38a815..9780f40ba3e6549e34f4c872e823cf718872dcff 100644 (file)
@@ -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;
                }