mtd: rawnand: ams-delta: Check mtd_device_register() return code
authorBoris Brezillon <boris.brezillon@bootlin.com>
Sun, 11 Nov 2018 07:55:12 +0000 (08:55 +0100)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Fri, 7 Dec 2018 09:38:25 +0000 (10:38 +0100)
mtd_device_register() can fail, and when it does we should propagate
the error and cleanup what has been done before.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Tested-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/nand/raw/ams-delta.c

index 0fc7563fba104e949fa9b2aad0884efb99ab415a..c59672a928322d1e566384e4f09b07f8cbdb73ac 100644 (file)
@@ -283,10 +283,16 @@ static int ams_delta_init(struct platform_device *pdev)
                goto err_unmap;
 
        /* Register the partitions */
-       mtd_device_register(mtd, partition_info, ARRAY_SIZE(partition_info));
+       err = mtd_device_register(mtd, partition_info,
+                                 ARRAY_SIZE(partition_info));
+       if (err)
+               goto err_nand_cleanup;
 
        return 0;
 
+err_nand_cleanup:
+       nand_cleanup(this);
+
 err_unmap:
        iounmap(io_base);