From: Florian Fainelli <f.fainelli@gmail.com>
To: Aditya Pakki <pakki001@umn.edu>
Cc: kjlu@umn.edu, Doug Berger <opendmb@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: ethernet: Fix phy_set_max_speed by checking for NULL
Date: Mon, 4 Mar 2019 15:40:52 -0800 [thread overview]
Message-ID: <cdf1690e-c1a3-3b36-7a41-566b2f646f85@gmail.com> (raw)
In-Reply-To: <20190304233622.13981-1-pakki001@umn.edu>
On 3/4/19 3:36 PM, Aditya Pakki wrote:
> phy_device can be a NULL pointer which is further dereferenced
> downstream in phy_set_max_speed. This patch avoids such a scenario.
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
> drivers/net/ethernet/broadcom/genet/bcmmii.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
> index aceb9b7b55bd..7eaaecb53aa2 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
> @@ -213,6 +213,8 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)
> break;
>
> case PHY_INTERFACE_MODE_MII:
> + if (!phydev)
> + return -ENODEV;
This is not where the error checking should go, it would be better to
move this in the caller of bcmgenet_mii_config(), that is
bcmgenet_mii_probe(), but there we already check that dev->phydev is non
NULL. The other code path where bcmgenet_mii_config() can be called is
from bcmgenet_resume(), which means the interface was sucessfully
registered and operation to begin with.
Was that flagged by some static analysis tool or human inspection?
--
Florian
prev parent reply other threads:[~2019-03-04 23:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-04 23:36 [PATCH] net: ethernet: Fix phy_set_max_speed by checking for NULL Aditya Pakki
2019-03-04 23:40 ` Florian Fainelli [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=cdf1690e-c1a3-3b36-7a41-566b2f646f85@gmail.com \
--to=f.fainelli@gmail.com \
--cc=davem@davemloft.net \
--cc=kjlu@umn.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=opendmb@gmail.com \
--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;
as well as URLs for NNTP newsgroup(s).