From: Marek Vasut <marek.vasut@gmail.com>
To: Boris Brezillon <boris.brezillon@free-electrons.com>,
"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>,
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:49:06 +0200 [thread overview]
Message-ID: <198201f8-ad5f-99d5-b357-9634185ca9e3@gmail.com> (raw)
In-Reply-To: <20170717224619.1615e13f@bbrezillon>
On 07/17/2017 10:46 PM, Boris Brezillon wrote:
> 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.
So how did you trigger the issue in the first place ?
--
Best regards,
Marek Vasut
prev parent reply other threads:[~2017-07-17 20:49 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
2017-07-17 20:49 ` Marek Vasut [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=198201f8-ad5f-99d5-b357-9634185ca9e3@gmail.com \
--to=marek.vasut@gmail.com \
--cc=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=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