From: Alexey Khoroshilov Date: Fri, 9 Feb 2018 22:28:36 +0000 (+0300) Subject: mtd: nand: vf610: check mtd_device_register() return code X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=1b8c90985f59ccd8a1adb723b58b42628b36e668;p=openwrt%2Fstaging%2Fblogic.git mtd: nand: vf610: check mtd_device_register() return code vf610_nfc_probe() misses error handling of mtd_device_register(). Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Reviewed-by: Stefan Agner Signed-off-by: Boris Brezillon --- diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c index 1939503b0960..5d7a1f8f580f 100644 --- a/drivers/mtd/nand/vf610_nfc.c +++ b/drivers/mtd/nand/vf610_nfc.c @@ -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;