axonram: Return directly after a failed kzalloc() in axon_ram_probe()
authorMarkus Elfring <elfring@users.sourceforge.net>
Thu, 3 Aug 2017 18:23:57 +0000 (20:23 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 1 Sep 2017 06:42:56 +0000 (16:42 +1000)
* Return directly after a call of the function "kzalloc" failed
  at the beginning.

* Delete a repeated check for the local variable "bank"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/sysdev/axonram.c

index ae359d78b7db642218c46e26e217b3f2ada6bae3..58507c3fbcd0709973d38ca8e4aba74385e4da69 100644 (file)
@@ -192,10 +192,8 @@ static int axon_ram_probe(struct platform_device *device)
                        device->dev.of_node);
 
        bank = kzalloc(sizeof(*bank), GFP_KERNEL);
-       if (bank == NULL) {
-               rc = -ENOMEM;
-               goto failed;
-       }
+       if (!bank)
+               return -ENOMEM;
 
        device->dev.platform_data = bank;
 
@@ -291,25 +289,22 @@ static int axon_ram_probe(struct platform_device *device)
        return 0;
 
 failed:
-       if (bank != NULL) {
-               if (bank->irq_id)
-                       free_irq(bank->irq_id, device);
-               if (bank->disk != NULL) {
-                       if (bank->disk->major > 0)
-                               unregister_blkdev(bank->disk->major,
-                                               bank->disk->disk_name);
-                       if (bank->disk->flags & GENHD_FL_UP)
-                               del_gendisk(bank->disk);
-                       put_disk(bank->disk);
-               }
-               kill_dax(bank->dax_dev);
-               put_dax(bank->dax_dev);
-               device->dev.platform_data = NULL;
-               if (bank->io_addr != 0)
-                       iounmap((void __iomem *) bank->io_addr);
-               kfree(bank);
+       if (bank->irq_id)
+               free_irq(bank->irq_id, device);
+       if (bank->disk != NULL) {
+               if (bank->disk->major > 0)
+                       unregister_blkdev(bank->disk->major,
+                                       bank->disk->disk_name);
+               if (bank->disk->flags & GENHD_FL_UP)
+                       del_gendisk(bank->disk);
+               put_disk(bank->disk);
        }
-
+       kill_dax(bank->dax_dev);
+       put_dax(bank->dax_dev);
+       device->dev.platform_data = NULL;
+       if (bank->io_addr != 0)
+               iounmap((void __iomem *) bank->io_addr);
+       kfree(bank);
        return rc;
 }