linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] mtd: spinand: Fix missing unlock on error path
@ 2018-07-04  8:29 Wei Yongjun
  2018-07-04  8:25 ` Boris Brezillon
  2018-07-04  9:21 ` [PATCH -next v2] mtd: spinand: fix missing unlock on error Wei Yongjun
  0 siblings, 2 replies; 7+ messages in thread
From: Wei Yongjun @ 2018-07-04  8:29 UTC (permalink / raw)
  To: Boris Brezillon, Miquel Raynal, Richard Weinberger,
	David Woodhouse, Brian Norris, Marek Vasut, Peter Pan,
	Frieder Schrempf
  Cc: Wei Yongjun, linux-mtd, linux-kernel, kernel-janitors

Add the missing unlock before return from function
spinand_mtd_(read|write) in the error handling case.

Fixes: c898e0526fb6 ("mtd: nand: Add core infrastructure to support SPI NANDs")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/mtd/nand/spi/core.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 17d207a..8ac1ba95 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -560,12 +560,16 @@ static int spinand_mtd_read(struct mtd_info *mtd, loff_t from,
 
 	nanddev_io_for_each_page(nand, from, ops, &iter) {
 		ret = spinand_select_target(spinand, iter.req.pos.target);
-		if (ret)
+		if (ret) {
+			mutex_unlock(&spinand->lock);
 			return ret;
+		}
 
 		ret = spinand_ecc_enable(spinand, enable_ecc);
-		if (ret)
+		if (ret) {
+			mutex_unlock(&spinand->lock);
 			return ret;
+		}
 
 		ret = spinand_read_page(spinand, &iter.req, enable_ecc);
 		if (ret < 0 && ret != -EBADMSG)
@@ -609,11 +613,11 @@ static int spinand_mtd_write(struct mtd_info *mtd, loff_t to,
 	nanddev_io_for_each_page(nand, to, ops, &iter) {
 		ret = spinand_select_target(spinand, iter.req.pos.target);
 		if (ret)
-			return ret;
+			break;
 
 		ret = spinand_ecc_enable(spinand, enable_ecc);
 		if (ret)
-			return ret;
+			break;
 
 		ret = spinand_write_page(spinand, &iter.req);
 		if (ret)


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

end of thread, other threads:[~2018-07-08 21:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-04  8:29 [PATCH -next] mtd: spinand: Fix missing unlock on error path Wei Yongjun
2018-07-04  8:25 ` Boris Brezillon
2018-07-04  9:21 ` [PATCH -next v2] mtd: spinand: fix missing unlock on error Wei Yongjun
2018-07-04  9:30   ` [PATCH -next v3] " Wei Yongjun
2018-07-05  6:59     ` Miquel Raynal
2018-07-05  8:48       ` weiyongjun (A)
2018-07-08 21:50     ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).