From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>, Kangjie Lu <kjlu@umn.edu>
Cc: pakki001@umn.edu, "David S. Miller" <davem@davemloft.net>,
Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Vladimir Barinov <vladimir.barinov@cogentembedded.com>,
Chris Brandt <chris.brandt@renesas.com>,
netdev <netdev@vger.kernel.org>,
Linux-Renesas <linux-renesas-soc@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] net: renesas: fix a potential NULL pointer dereference
Date: Mon, 11 Mar 2019 13:43:18 +0300 [thread overview]
Message-ID: <73506a39-1c8c-b5dc-d5df-6f9dc51c09aa@cogentembedded.com> (raw)
In-Reply-To: <CAMuHMdUcc2MXwX1sP4QEiWskoDofR8HQv-e2f9nWXhaMPeeZYA@mail.gmail.com>
Hello!
On 03/11/2019 10:43 AM, Geert Uytterhoeven wrote:
>> In case of_get_phy_mode fails, the fix returns NULL to avoid
>> the NULL pointer dereference.
>>
>> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
>
> Thanks for your patch!
>
>> --- a/drivers/net/ethernet/renesas/sh_eth.c
>> +++ b/drivers/net/ethernet/renesas/sh_eth.c
>> @@ -3187,6 +3187,8 @@ static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev)
>> return NULL;
>>
>> pdata->phy_interface = of_get_phy_mode(np);
>> + if (unlikely(!pdata->phy_interface))
>> + return NULL;
>
> of_get_phy_mode() does not return a pointer, but a phy mode index.
> Hence zero is a valid value.
>
> So I'm wondering where is the potential NULL pointer dereference?
Hm, not seeing NULL deref as well...
> Perhaps we do need to check for negative error codes?
> Or is this already handled later, by {of_,}phy_connect()?
Not seeing such handling too...
The v2 patch seems good though, as the "phy-mode" prop is mandatory anyway.
> Gr{oetje,eeting}s,
>
> Geert
MBR, Sergei
prev parent reply other threads:[~2019-03-11 10:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-11 7:01 Kangjie Lu
2019-03-11 7:43 ` Geert Uytterhoeven
2019-03-11 10:43 ` Sergei Shtylyov [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=73506a39-1c8c-b5dc-d5df-6f9dc51c09aa@cogentembedded.com \
--to=sergei.shtylyov@cogentembedded.com \
--cc=chris.brandt@renesas.com \
--cc=davem@davemloft.net \
--cc=geert+renesas@glider.be \
--cc=geert@linux-m68k.org \
--cc=kjlu@umn.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pakki001@umn.edu \
--cc=vladimir.barinov@cogentembedded.com \
--cc=vladimir_zapolskiy@mentor.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 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®