From: Miquel Raynal Date: Wed, 21 Mar 2018 13:01:42 +0000 (+0100) Subject: mtd: rawnand: brcmnand: fix probe function error path X-Git-Tag: v4.19~1278^2~1^2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5826b8802a970d2b0aaf097951de42040ee32480;p=platform%2Fkernel%2Flinux-rpi3.git mtd: rawnand: brcmnand: fix probe function error path An error after nand_scan_tail() should trigger a nand_cleanup(). The helper mtd_device_register() returns an error code that should be checked and nand_cleanup() called accordingly. Signed-off-by: Miquel Raynal Signed-off-by: Boris Brezillon --- diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c index c28fd2b..1306aaa 100644 --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c @@ -2297,7 +2297,11 @@ static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn) 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; } static void brcmnand_save_restore_cs_config(struct brcmnand_host *host,