From: Richard Weinberger <richard@nod.at>
To: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
marek.vasut@gmail.com, cyrille.pitchen@wedev4u.fr,
computersforpeace@gmail.com, dwmw2@infradead.org
Subject: Re: [PATCH] mtd: spi-nor: Check for spi_nor_hwcaps_read2cmd() return value
Date: Mon, 18 Sep 2017 15:39:25 +0200 [thread overview]
Message-ID: <2454131.y020cBOLnt@blindfold> (raw)
In-Reply-To: <20170918113945.1549571f@bbrezillon>
Am Montag, 18. September 2017, 11:39:45 CEST schrieb Boris Brezillon:
> On Sun, 17 Sep 2017 11:57:50 +0200
>
> Richard Weinberger <richard@nod.at> wrote:
> > The function can return a negativ value in case of errors,
> > don't use it blindly as array index.
> >
> > Detected by CoverityScan CID#1418067 ("Memory - illegal accesses")
> > Fixes: f384b352cbf0 ("mtd: spi-nor: parse Serial Flash Discoverable
> > Parameters (SFDP) tables")
>
> Hm, not sure but I think "Fixes:" should not be wrapped.
Hmm, vi tried to be smart. ;-\
>
> > Signed-off-by: Richard Weinberger <richard@nod.at>
> > ---
> >
> > drivers/mtd/spi-nor/spi-nor.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> > index cf1d4a15e10a..d71765739a93 100644
> > --- a/drivers/mtd/spi-nor/spi-nor.c
> > +++ b/drivers/mtd/spi-nor/spi-nor.c
> > @@ -2145,6 +2145,9 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
> >
> > params->hwcaps.mask |= rd->hwcaps;
> > cmd = spi_nor_hwcaps_read2cmd(rd->hwcaps);
> >
> > + if (cmd < 0)
> > + return -EINVAL;
>
> Why not returning cmd directly?
I thought about that too but the only other user of that function also returns
-EINVAL upon error.
Maybe Cyrille can give more input whether we should propagate
spi_nor_hwcaps_read2cmd()'s return values or not.
Thanks,
//richard
next prev parent reply other threads:[~2017-09-18 13:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-17 9:57 [PATCH] mtd: spi-nor: Check for spi_nor_hwcaps_read2cmd() return value Richard Weinberger
2017-09-18 9:39 ` Boris Brezillon
2017-09-18 13:39 ` Richard Weinberger [this message]
2017-09-19 17:33 ` Cyrille Pitchen
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=2454131.y020cBOLnt@blindfold \
--to=richard@nod.at \
--cc=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@wedev4u.fr \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.