diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2016-11-25 12:01:32 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-12-12 03:15:48 +0100 |
commit | efca4885b5dea6af906d27b3516f68e0bc1ff9c3 (patch) | |
tree | e160e8a90a7b8fc8c4edb22cb57029eeedeff72e /arch/sparc | |
parent | sparc: kernel: use builtin_platform_driver (diff) | |
download | linux-efca4885b5dea6af906d27b3516f68e0bc1ff9c3.tar.xz linux-efca4885b5dea6af906d27b3516f68e0bc1ff9c3.zip |
sparc64: move dereference after check for NULL
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>
Diffstat (limited to 'arch/sparc')
-rw-r--r-- | arch/sparc/kernel/pci_sun4v.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c index 06981cc716b6..cabb609fedcc 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; |