OSDN Git Service

mtd: nand: vf610: check mtd_device_register() return code
authorAlexey Khoroshilov <khoroshilov@ispras.ru>
Fri, 9 Feb 2018 22:28:36 +0000 (01:28 +0300)
committerBoris Brezillon <boris.brezillon@bootlin.com>
Mon, 12 Feb 2018 22:36:05 +0000 (23:36 +0100)
vf610_nfc_probe() misses error handling of mtd_device_register().

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Reviewed-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
drivers/mtd/nand/vf610_nfc.c

index 1939503..5d7a1f8 100644 (file)
@@ -767,8 +767,13 @@ static int vf610_nfc_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, mtd);
 
        /* Register device in MTD */
-       return mtd_device_register(mtd, NULL, 0);
+       err = mtd_device_register(mtd, NULL, 0);
+       if (err)
+               goto err_cleanup_nand;
+       return 0;
 
+err_cleanup_nand:
+       nand_cleanup(chip);
 err_disable_clk:
        clk_disable_unprepare(nfc->clk);
        return err;