public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 1/2] mtd: nand: gpmi: Fix gpmi_nand_init() error path
@ 2017-04-10  8:35 Boris Brezillon
  2017-04-10  8:35 ` [PATCH 2/2] mtd: nand: gpmi: Kill gpmi_nand_exit() Boris Brezillon
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Boris Brezillon @ 2017-04-10  8:35 UTC (permalink / raw)
  To: Boris Brezillon, Richard Weinberger, linux-mtd
  Cc: David Woodhouse, Brian Norris, Marek Vasut, Cyrille Pitchen,
	Han Xu, Shawn Guo, Sascha Hauer, Leonard Crestez, Masahiro Yamada

The GPMI driver is wrongly assuming that nand_release() can safely be
called on an uninitialized/unregistered NAND device.

Add a new err_nand_cleanup label in the error path and only execute if
nand_scan_tail() succeeded.

Note that we now call nand_cleanup() instead of nand_release()
(nand_release() is actually grouping the mtd_device_unregister() and
nand_cleanup() in one call) because there's no point in trying to
unregister a device that has never been registered.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index d52139635b67..92279a0d52f1 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -2048,18 +2048,20 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
 
 	ret = nand_boot_init(this);
 	if (ret)
-		goto err_out;
+		goto err_nand_cleanup;
 	ret = chip->scan_bbt(mtd);
 	if (ret)
-		goto err_out;
+		goto err_nand_cleanup;
 
 	ret = mtd_device_register(mtd, NULL, 0);
 	if (ret)
-		goto err_out;
+		goto err_nand_cleanup;
 	return 0;
 
+err_nand_cleanup:
+	nand_cleanup(chip);
 err_out:
-	gpmi_nand_exit(this);
+	gpmi_free_dma_buffer(this);
 	return ret;
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-05-15 19:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-10  8:35 [PATCH 1/2] mtd: nand: gpmi: Fix gpmi_nand_init() error path Boris Brezillon
2017-04-10  8:35 ` [PATCH 2/2] mtd: nand: gpmi: Kill gpmi_nand_exit() Boris Brezillon
2017-04-15 14:58   ` Marek Vasut
2017-04-17 16:55     ` Han Xu
2017-04-15 14:58 ` [PATCH 1/2] mtd: nand: gpmi: Fix gpmi_nand_init() error path Marek Vasut
2017-04-17 16:50   ` Han Xu
2017-05-15 19:40 ` Boris Brezillon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox