From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1eydOD-0001Yf-5C for linux-mtd@lists.infradead.org; Wed, 21 Mar 2018 13:02:55 +0000 From: Miquel Raynal To: Boris Brezillon , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut Cc: linux-mtd@lists.infradead.org, Kamal Dasu , Masahiro Yamada , Miquel Raynal Subject: [PATCH v2 10/16] mtd: rawnand: omap2: fix the probe function error path Date: Wed, 21 Mar 2018 14:01:51 +0100 Message-Id: <20180321130157.9524-11-miquel.raynal@bootlin.com> In-Reply-To: <20180321130157.9524-1-miquel.raynal@bootlin.com> References: <20180321130157.9524-1-miquel.raynal@bootlin.com> List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , An error after nand_scan_tail() should trigger a nand_cleanup(). The helper mtd_device_parse_register() returns an error code that should be checked and nand_cleanup() called accordingly. Signed-off-by: Miquel Raynal --- drivers/mtd/nand/raw/omap2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/omap2.c b/drivers/mtd/nand/raw/omap2.c index 8cdf7d3d8fa7..02dfd2e66938 100644 --- a/drivers/mtd/nand/raw/omap2.c +++ b/drivers/mtd/nand/raw/omap2.c @@ -2263,12 +2263,14 @@ static int omap_nand_probe(struct platform_device *pdev) err = mtd_device_register(mtd, NULL, 0); if (err) - goto return_error; + goto cleanup_nand; platform_set_drvdata(pdev, mtd); return 0; +cleanup_nand: + nand_cleanup(nand_chip); return_error: if (!IS_ERR_OR_NULL(info->dma)) dma_release_channel(info->dma); @@ -2276,6 +2278,7 @@ static int omap_nand_probe(struct platform_device *pdev) nand_bch_free(nand_chip->ecc.priv); nand_chip->ecc.priv = NULL; } + return err; } -- 2.14.1