summaryrefslogtreecommitdiff
path: root/drivers/iommu
diff options
context:
space:
mode:
authorArtem Chernyshev <artem.chernyshev@red-soft.ru>2024-07-16 15:55:14 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-08-03 08:49:53 +0200
commitdfe90030a0cfa26dca4cb6510de28920e5ad22fb (patch)
tree6efd55c954a45b684d16d413ecc7da081b690ce0 /drivers/iommu
parentf82bc4a04a95894a9bbf3f54808950aad7a88b6e (diff)
downloadlinux-dfe90030a0cfa26dca4cb6510de28920e5ad22fb.tar.gz
linux-dfe90030a0cfa26dca4cb6510de28920e5ad22fb.tar.bz2
linux-dfe90030a0cfa26dca4cb6510de28920e5ad22fb.zip
iommu: sprd: Avoid NULL deref in sprd_iommu_hw_en
[ Upstream commit 630482ee0653decf9e2482ac6181897eb6cde5b8 ] 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: 9afea57384d4 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/sprd-iommu.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iommu/sprd-iommu.c b/drivers/iommu/sprd-iommu.c
index e4358393fe37..71d22daaec2e 100644
--- a/drivers/iommu/sprd-iommu.c
+++ b/drivers/iommu/sprd-iommu.c
@@ -234,8 +234,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)