public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] sparc64: move dereference after check for NULL
@ 2016-11-25 11:01 Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2016-11-25 11:01 UTC (permalink / raw)
  To: kernel-janitors

We shouldn't dereference "iommu" until after we have checked that it is
non-NULL.

Fixes: f08978b0fdbf ("sparc64: Enable sun4v dma ops to use IOMMU v2 APIs")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Applies to sparc.git

diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c
index 06981cc7..cabb609 100644
--- a/arch/sparc/kernel/pci_sun4v.c
+++ b/arch/sparc/kernel/pci_sun4v.c
@@ -478,11 +478,10 @@ static int dma_4v_map_sg(struct device *dev, struct scatterlist *sglist,
 	BUG_ON(direction = DMA_NONE);
 
 	iommu = dev->archdata.iommu;
-	atu = iommu->atu;
-
 	if (nelems = 0 || !iommu)
 		return 0;
-	
+	atu = iommu->atu;
+
 	prot = HV_PCI_MAP_ATTR_READ;
 	if (direction != DMA_TO_DEVICE)
 		prot |= HV_PCI_MAP_ATTR_WRITE;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] sparc64: move dereference after check for NULL
@ 2016-12-12  2:18 David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-12-12  2:18 UTC (permalink / raw)
  To: kernel-janitors

From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Fri, 25 Nov 2016 14:01:32 +0300

> We shouldn't dereference "iommu" until after we have checked that it is
> non-NULL.
> 
> Fixes: f08978b0fdbf ("sparc64: Enable sun4v dma ops to use IOMMU v2 APIs")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-12-12  2:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-25 11:01 [patch] sparc64: move dereference after check for NULL Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2016-12-12  2:18 David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox