Commit 630482ee authored by Artem Chernyshev's avatar Artem Chernyshev Committed by Will Deacon

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: 9afea573 ("iommu/sprd: Release dma buffer to avoid memory leak")
Signed-off-by: default avatarArtem Chernyshev <artem.chernyshev@red-soft.ru>
Reviewed-by: default avatarChunyan Zhang <zhang.lyra@gmail.com>
Link: https://lore.kernel.org/r/20240716125522.3690358-1-artem.chernyshev@red-soft.ruSigned-off-by: default avatarWill Deacon <will@kernel.org>
parent 8b6c32e8
......@@ -232,8 +232,8 @@ static void sprd_iommu_cleanup(struct sprd_iommu_domain *dom)
pgt_size = sprd_iommu_pgt_size(&dom->domain);
dma_free_coherent(dom->sdev->dev, pgt_size, dom->pgt_va, dom->pgt_pa);
dom->sdev = NULL;
sprd_iommu_hw_en(dom->sdev, false);
dom->sdev = NULL;
}
static void sprd_iommu_domain_free(struct iommu_domain *domain)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment