From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
Cc: Stefan Agner <stefan@agner.ch>,
Richard Weinberger <richard@nod.at>,
David Woodhouse <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>,
Marek Vasut <marek.vasut@gmail.com>,
Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mtd: nand: vf610_nfc: add NULL check on of_match_device() return value
Date: Mon, 17 Jul 2017 22:46:19 +0200 [thread overview]
Message-ID: <20170717224619.1615e13f@bbrezillon> (raw)
In-Reply-To: <20170707065926.GA25776@embeddedgus>
Le Fri, 7 Jul 2017 01:59:26 -0500,
"Gustavo A. R. Silva" <garsilva@embeddedor.com> a écrit :
> Check return value from call to of_match_device()
> in order to prevent a NULL pointer dereference.
>
> In case of NULL print error message and return -ENODEV
>
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
> drivers/mtd/nand/vf610_nfc.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c
> index 744ab10..ca0ab96 100644
> --- a/drivers/mtd/nand/vf610_nfc.c
> +++ b/drivers/mtd/nand/vf610_nfc.c
> @@ -674,6 +674,11 @@ static int vf610_nfc_probe(struct platform_device *pdev)
> }
>
> of_id = of_match_device(vf610_nfc_dt_ids, &pdev->dev);
> + if (!of_id) {
> + dev_err(&pdev->dev, "Failed to match device!\n");
> + return -ENODEV;
> + }
> +
While this check is functionally correct, this case cannot happen,
because this is DT-only driver, and without a valid match in
vf610_nfc_dt_ids the dev wouldn't have been probed in the first place.
I'll let Stefan decide whether he wants it or not, but I see no real
reason for this extra check.
> nfc->variant = (enum vf610_nfc_variant)of_id->data;
>
> for_each_available_child_of_node(nfc->dev->of_node, child) {
next prev parent reply other threads:[~2017-07-17 20:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-07 6:59 [PATCH] mtd: nand: vf610_nfc: add NULL check on of_match_device() return value Gustavo A. R. Silva
2017-07-17 20:46 ` Boris Brezillon [this message]
2017-07-17 20:49 ` Marek Vasut
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=20170717224619.1615e13f@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@wedev4u.fr \
--cc=dwmw2@infradead.org \
--cc=garsilva@embeddedor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--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