Skip to content

Commit 630482e

Browse files
dTenebraewilldeacon
authored andcommitted
iommu: sprd: Avoid NULL deref in sprd_iommu_hw_en
In sprd_iommu_cleanup() before calling function sprd_iommu_hw_en() dom->sdev is equal to NULL, which leads to null dereference. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 9afea57 ("iommu/sprd: Release dma buffer to avoid memory leak") Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru> Reviewed-by: Chunyan Zhang <zhang.lyra@gmail.com> Link: https://lore.kernel.org/r/20240716125522.3690358-1-artem.chernyshev@red-soft.ru Signed-off-by: Will Deacon <will@kernel.org>
1 parent 8b6c32e commit 630482e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/iommu/sprd-iommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ static void sprd_iommu_cleanup(struct sprd_iommu_domain *dom)
232232

233233
pgt_size = sprd_iommu_pgt_size(&dom->domain);
234234
dma_free_coherent(dom->sdev->dev, pgt_size, dom->pgt_va, dom->pgt_pa);
235-
dom->sdev = NULL;
236235
sprd_iommu_hw_en(dom->sdev, false);
236+
dom->sdev = NULL;
237237
}
238238

239239
static void sprd_iommu_domain_free(struct iommu_domain *domain)

0 commit comments

Comments
 (0)