clear-pkgs-linux-iot-lts2018/1038-ipu-mmu.c-Fix-possible...

49 lines
1.6 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Anil Kumar <anil.kumar.k@intel.com>
Date: Fri, 15 Mar 2019 10:22:16 -0700
Subject: [PATCH] ipu-mmu.c: Fix possible null pointer dereference
Change-Id: I85281c8b164b095b3cdf150d4a560d1c86c0c425
Signed-off-by: Anil Kumar <anil.kumar.k@intel.com>
Tracked-On: PKT-1814
---
drivers/media/pci/intel/ipu-mmu.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/drivers/media/pci/intel/ipu-mmu.c b/drivers/media/pci/intel/ipu-mmu.c
2020-10-27 02:14:06 +08:00
index 7718732fe5e6..968c55316e6d 100644
--- a/drivers/media/pci/intel/ipu-mmu.c
+++ b/drivers/media/pci/intel/ipu-mmu.c
@@ -341,16 +341,19 @@ static void ipu_mmu_domain_destroy(struct iommu_domain *domain)
if (adom->iova_addr_trash) {
iova = find_iova(&adom->dmap->iovad, adom->iova_addr_trash >>
PAGE_SHIFT);
- /* unmap and free the corresponding trash buffer iova */
- iommu_unmap(domain, iova->pfn_lo << PAGE_SHIFT,
- (iova->pfn_hi - iova->pfn_lo + 1) << PAGE_SHIFT);
- __free_iova(&adom->dmap->iovad, iova);
- /*
- * Set iova_addr_trash in mmu to 0, so that on next HW init
- * this will be mapped again.
- */
- adom->iova_addr_trash = 0;
+ if (iova) {
+ /* unmap and free the corresponding trash buffer iova */
+ iommu_unmap(domain, iova->pfn_lo << PAGE_SHIFT,
+ (iova->pfn_hi - iova->pfn_lo + 1) << PAGE_SHIFT);
+ __free_iova(&adom->dmap->iovad, iova);
+
+ /*
+ * Set iova_addr_trash in mmu to 0, so that on next HW init
+ * this will be mapped again.
+ */
+ adom->iova_addr_trash = 0;
+ }
}
for (l1_idx = 0; l1_idx < ISP_L1PT_PTES; l1_idx++)
--
https://clearlinux.org