From: Hans Verkuil <hverkuil@xs4all.nl>
To: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>,
"Kangjie Lu" <kjlu@umn.edu>
Cc: pakki001@umn.edu, Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: rcar-vin: fix a potential NULL pointer dereference
Date: Thu, 28 Mar 2019 16:26:03 +0100 [thread overview]
Message-ID: <c16cbf21-562a-ba00-020e-6232fc27e9f9@xs4all.nl> (raw)
In-Reply-To: <20190309110217.GA5281@bigcity.dyn.berto.se>
On 3/9/19 12:02 PM, Niklas Söderlund wrote:
> Hi Kangjie,
>
> Thanks for your patch.
>
> On 2019-03-09 01:05:27 -0600, Kangjie Lu wrote:
>> In case of_match_node cannot find a match, the fix returns
>> -EINVAL to avoid NULL pointer dereference.
>>
>> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
>> ---
>> drivers/media/platform/rcar-vin/rcar-core.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
>> index f0719ce24b97..a058e2023ca8 100644
>> --- a/drivers/media/platform/rcar-vin/rcar-core.c
>> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
>> @@ -266,6 +266,8 @@ static int rvin_group_init(struct rvin_group *group, struct rvin_dev *vin)
>>
>> match = of_match_node(vin->dev->driver->of_match_table,
>> vin->dev->of_node);
>> + if (unlikely(!match))
>> + return -EINVAL;
>
> I don't think this is needed. The driver depends on selects OF and if we
> get this far we it is because we had a match already. The reason to call
> of_match_node() here is simply to retrieve which of the possible
> compatible strings was matched.
>
> Am I missing something? What scenario do you see where this can fail?
And even if it can fail, then please drop the 'unlikely'.
Regards,
Hans
>
>>
>> strscpy(mdev->driver_name, KBUILD_MODNAME, sizeof(mdev->driver_name));
>> strscpy(mdev->model, match->compatible, sizeof(mdev->model));
>> --
>> 2.17.1
>>
>
prev parent reply other threads:[~2019-03-28 15:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-09 7:05 Kangjie Lu
2019-03-09 11:02 ` Niklas Söderlund
2019-03-28 15:26 ` Hans Verkuil [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=c16cbf21-562a-ba00-020e-6232fc27e9f9@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=kjlu@umn.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=niklas.soderlund@ragnatech.se \
--cc=pakki001@umn.edu \
/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
all inboxes | Powered by JetHome®