From: Boris Brezillon <boris.brezillon@collabora.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Aditya Pakki <pakki001@umn.edu>,
kjlu@umn.edu, Stefan Agner <stefan@agner.ch>,
Boris Brezillon <bbrezillon@kernel.org>,
Richard Weinberger <richard@nod.at>,
David Woodhouse <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>,
Marek Vasut <marek.vasut@gmail.com>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mtd: rawnand: vf610: Fix to check for NULL pointer dereference
Date: Mon, 1 Apr 2019 17:30:56 +0200 [thread overview]
Message-ID: <20190401173056.17604b54@collabora.com> (raw)
In-Reply-To: <20190401172651.158c05fe@xps13>
On Mon, 1 Apr 2019 17:26:51 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> Hi Aditya,
>
> Aditya Pakki <pakki001@umn.edu> wrote on Mon, 18 Mar 2019 18:24:34
> -0500:
>
> > of_match_device can return NULL if there is no matching device is found.
> > The patch avoids a potential NULL pointer dereference by checking for the
> > return value and passing the error upstream.
> >
> > Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> > ---
> > drivers/mtd/nand/raw/vf610_nfc.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c
> > index a662ca1970e5..946abbb275c3 100644
> > --- a/drivers/mtd/nand/raw/vf610_nfc.c
> > +++ b/drivers/mtd/nand/raw/vf610_nfc.c
> > @@ -850,6 +850,8 @@ static int vf610_nfc_probe(struct platform_device *pdev)
> > }
> >
> > of_id = of_match_device(vf610_nfc_dt_ids, &pdev->dev);
> > + if (!of_id)
> > + return -ENODEV;
For the record, this can't happen unless you have serious memory
corruption issues since you reached the ->probe() function (which means
a match was found before).
> > nfc->variant = (enum vf610_nfc_variant)of_id->data;
> >
> > for_each_available_child_of_node(nfc->dev->of_node, child) {
>
>
> Applied to git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git
> on nand/next with the title changed to
>
> mtd: rawnand: vf610: Avoid a potential NULL pointer dereference
>
> and a space after the return statement.
>
> Thanks,
> Miquèl
prev parent reply other threads:[~2019-04-01 15:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-18 23:24 [PATCH] mtd: rawnand: vf610: Fix to check for NULL pointer dereference Aditya Pakki
2019-04-01 15:26 ` Miquel Raynal
2019-04-01 15:30 ` Boris Brezillon [this message]
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=20190401173056.17604b54@collabora.com \
--to=boris.brezillon@collabora.com \
--cc=bbrezillon@kernel.org \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=kjlu@umn.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=miquel.raynal@bootlin.com \
--cc=pakki001@umn.edu \
--cc=richard@nod.at \
--cc=stefan@agner.ch \
/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