mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: "Clément Leger" <cleger@kalray.eu>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH] Phy: Check NULL bus case and undetected phy via of
Date: Wed, 6 Sep 2017 14:46:05 +0200	[thread overview]
Message-ID: <20170906124605.euisfttxsywl4thj@pengutronix.de> (raw)
In-Reply-To: <1566403872.328360912.1504601784430.JavaMail.zimbra@kalray.eu>

On Tue, Sep 05, 2017 at 10:56:24AM +0200, Clément Leger wrote:
> From 5e87dc2c24051c2cd2985e513c5a825d51d9bb00 Mon Sep 17 00:00:00 2001
> From: Clement Leger <clement.leger@kalray.eu>
> Date: Tue, 5 Sep 2017 10:37:23 +0200
> Subject: [PATCH] Phy: Check NULL bus case and undetected phy via of
> 
> phy_device_connect can be called with NULL miibus for automatic match
> with the phy described in the device tree. In the case where the phy
> was not detected for some unknown reason, the next calls will be done
> with a NULL bus. This will lead to undefined behavior and more probably
> crashes.
> ---
>  drivers/net/phy/phy.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 

Applied, thanks

Sascha

> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 7132516..e8f7726 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -405,6 +405,11 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
>  		goto out;
>  	}
>  
> +	if (!bus) {
> +		ret = -ENODEV;
> +		goto out;
> +	}
> +
>  	if (addr >= 0) {
>  		phy = mdiobus_scan(bus, addr);
>  		if (IS_ERR(phy)) {
> -- 
> 1.8.3.1
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2017-09-06 12:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-05  8:56 Clément Leger
2017-09-06 12:46 ` Sascha Hauer [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=20170906124605.euisfttxsywl4thj@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=cleger@kalray.eu \
    /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