summaryrefslogtreecommitdiff
path: root/arch/powerpc/kernel/iommu.c
diff options
context:
space:
mode:
authorBreno Leitao <leitao@debian.org>2018-08-21 15:44:48 -0300
committerMichael Ellerman <mpe@ellerman.id.au>2018-09-19 21:58:09 +1000
commit984ecdd68de0fa1f63ce205d6c19ef5a7bc67b40 (patch)
tree4eb2bb5bf308d08eb4791b8cd5b34f4863019cb2 /arch/powerpc/kernel/iommu.c
parent8ac9e5bfd8cf41ef106ac97267117e5209627c74 (diff)
downloadlwn-984ecdd68de0fa1f63ce205d6c19ef5a7bc67b40.tar.gz
lwn-984ecdd68de0fa1f63ce205d6c19ef5a7bc67b40.zip
powerpc/iommu: Avoid derefence before pointer check
The tbl pointer is being derefenced by IOMMU_PAGE_SIZE prior the check if it is not NULL. Just moving the dereference code to after the check, where there will be guarantee that 'tbl' will not be NULL. Signed-off-by: Breno Leitao <leitao@debian.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/kernel/iommu.c')
-rw-r--r--arch/powerpc/kernel/iommu.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index af7a20dc6e09..80b6caaa9b92 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -785,9 +785,9 @@ dma_addr_t iommu_map_page(struct device *dev, struct iommu_table *tbl,
vaddr = page_address(page) + offset;
uaddr = (unsigned long)vaddr;
- npages = iommu_num_pages(uaddr, size, IOMMU_PAGE_SIZE(tbl));
if (tbl) {
+ npages = iommu_num_pages(uaddr, size, IOMMU_PAGE_SIZE(tbl));
align = 0;
if (tbl->it_page_shift < PAGE_SHIFT && size >= PAGE_SIZE &&
((unsigned long)vaddr & ~PAGE_MASK) == 0)