From: Miquel Raynal Date: Sun, 25 Feb 2018 22:09:14 +0000 (+0100) Subject: mtd: rawnand: sm_common: fix the probe function error path X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=92aa292d2e47be6210c0ba6074fc0ddfc02f7856;p=linux.git mtd: rawnand: sm_common: fix the probe function error path nand_cleanup() should be called upon error after a successful nand_scan_tail(). Rework the error path to follow this rule . Signed-off-by: Miquel Raynal --- diff --git a/drivers/mtd/nand/raw/sm_common.c b/drivers/mtd/nand/raw/sm_common.c index 7f5044a79f013..8bd16639ef85e 100644 --- a/drivers/mtd/nand/raw/sm_common.c +++ b/drivers/mtd/nand/raw/sm_common.c @@ -192,7 +192,11 @@ int sm_register_device(struct mtd_info *mtd, int smartmedia) if (ret) return ret; - return mtd_device_register(mtd, NULL, 0); + ret = mtd_device_register(mtd, NULL, 0); + if (ret) + nand_cleanup(chip); + + return ret; } EXPORT_SYMBOL_GPL(sm_register_device);