* [PATCH] powerpc/iommu: avoid derefence before pointer check
@ 2018-08-21 18:44 Breno Leitao
2018-09-20 4:20 ` Michael Ellerman
0 siblings, 1 reply; 2+ messages in thread
From: Breno Leitao @ 2018-08-21 18:44 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Alistair Popple, Breno Leitao
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.
CC: Alistair Popple <alistair@popple.id.au>
Signed-off-by: Breno Leitao <leitao@debian.org>
---
arch/powerpc/kernel/iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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)
--
2.16.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-09-20 4:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-21 18:44 [PATCH] powerpc/iommu: avoid derefence before pointer check Breno Leitao
2018-09-20 4:20 ` Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).