]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
sparc64: move dereference after check for NULL
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 25 Nov 2016 11:01:32 +0000 (14:01 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 12 Dec 2016 02:15:48 +0000 (18:15 -0800)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
arch/sparc/kernel/pci_sun4v.c

index 06981cc716b68022712dc3a872e611565e4e4817..cabb609fedcc9a7ab6b544a5ec7c1be20beaa74b 100644 (file)
@@ -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;