瀏覽代碼

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 <miquel.raynal@bootlin.com>
Miquel Raynal 7 年之前
父節點
當前提交
92aa292d2e
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      drivers/mtd/nand/raw/sm_common.c

+ 5 - 1
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);