From: Boris Brezillon <boris.brezillon@bootlin.com>
To: Wei Yongjun <weiyongjun1@huawei.com>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
"David Woodhouse" <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>,
Marek Vasut <marek.vasut@gmail.com>,
Peter Pan <peterpandong@micron.com>,
Frieder Schrempf <frieder.schrempf@exceet.de>,
<linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH -next] mtd: spinand: Fix missing unlock on error path
Date: Wed, 4 Jul 2018 10:25:31 +0200 [thread overview]
Message-ID: <20180704102531.7af9a2e6@bbrezillon> (raw)
In-Reply-To: <1530692979-6274-1-git-send-email-weiyongjun1@huawei.com>
On Wed, 4 Jul 2018 08:29:39 +0000
Wei Yongjun <weiyongjun1@huawei.com> wrote:
> 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;
> + }
Why not
if (ret)
break;
?
>
> ret = spinand_ecc_enable(spinand, enable_ecc);
> - if (ret)
> + if (ret) {
> + mutex_unlock(&spinand->lock);
> return ret;
> + }
Ditto.
>
> 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)
>
next prev parent reply other threads:[~2018-07-04 8:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-04 8:29 [PATCH -next] mtd: spinand: Fix missing unlock on error path Wei Yongjun
2018-07-04 8:25 ` Boris Brezillon [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180704102531.7af9a2e6@bbrezillon \
--to=boris.brezillon@bootlin.com \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=frieder.schrempf@exceet.de \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=miquel.raynal@bootlin.com \
--cc=peterpandong@micron.com \
--cc=richard@nod.at \
--cc=weiyongjun1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox