Commit 5941f0e0 authored by Ryan Huang's avatar Ryan Huang Committed by Will Deacon
Browse files

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: e3b1be2e ("iommu/arm-smmu-v3: Reorganize struct arm_smmu_ctx_desc_cfg")
Signed-off-by: default avatarDaniel Mentz <danielmentz@google.com>
Signed-off-by: default avatarRyan Huang <tzukui@google.com>
Reviewed-by: default avatarNicolin Chen <nicolinc@nvidia.com>
Reviewed-by: default avatarPranjal Shrivastava <praan@google.com>
Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Signed-off-by: default avatarWill Deacon <will@kernel.org>
parent 617937d4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
		}