parisc: ccio-dma: Handle return NULL error from ioremap_nocache
authorArvind Yadav <arvind.yadav.cs@gmail.com>
Thu, 2 Feb 2017 13:22:34 +0000 (18:52 +0530)
committerHelge Deller <deller@gmx.de>
Sat, 25 Feb 2017 21:27:30 +0000 (22:27 +0100)
Fix error paths and return -ENOMEM instead of '1'.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
drivers/parisc/ccio-dma.c

index 553ef8a5d588685ff02f98bde7110dfb421accaa..b0558e2451b568b1896ba3a660404ac2da6d9c74 100644 (file)
@@ -1539,7 +1539,7 @@ static int __init ccio_probe(struct parisc_device *dev)
        ioc = kzalloc(sizeof(struct ioc), GFP_KERNEL);
        if (ioc == NULL) {
                printk(KERN_ERR MODULE_NAME ": memory allocation failure\n");
-               return 1;
+               return -ENOMEM;
        }
 
        ioc->name = dev->id.hversion == U2_IOA_RUNWAY ? "U2" : "UTurn";
@@ -1554,6 +1554,10 @@ static int __init ccio_probe(struct parisc_device *dev)
 
        ioc->hw_path = dev->hw_path;
        ioc->ioc_regs = ioremap_nocache(dev->hpa.start, 4096);
+       if (!ioc->ioc_regs) {
+               kfree(ioc);
+               return -ENOMEM;
+       }
        ccio_ioc_init(ioc);
        ccio_init_resources(ioc);
        hppa_dma_ops = &ccio_ops;