diff mbox

[2/2] net: dsa: remove phy_disconnect from error path

Message ID 1455187489-30771-2-git-send-email-s.hauer@pengutronix.de
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Sascha Hauer Feb. 11, 2016, 10:44 a.m. UTC
The phy has not been initialized, disconnecting it in the error
path results in a NULL pointer exception. Drop the phy_disconnect
from the error path.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 net/dsa/slave.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Vivien Didelot Feb. 11, 2016, 3:39 p.m. UTC | #1
Hi Sascha,

Sascha Hauer <s.hauer@pengutronix.de> writes:

> The phy has not been initialized, disconnecting it in the error
> path results in a NULL pointer exception. Drop the phy_disconnect
> from the error path.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  net/dsa/slave.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index 40b9ca7..91e3b2f 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -1194,7 +1194,6 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
>  	if (ret) {
>  		netdev_err(master, "error %d registering interface %s\n",
>  			   ret, slave_dev->name);
> -		phy_disconnect(p->phy);
>  		ds->ports[port] = NULL;
>  		free_netdev(slave_dev);
>  		return ret;

I'm adding Neil in the loop, since he did some work similar to this, if
I'm not mistaken.

Thanks,
-v
Andrew Lunn Feb. 11, 2016, 3:48 p.m. UTC | #2
On Thu, Feb 11, 2016 at 11:44:49AM +0100, Sascha Hauer wrote:
> The phy has not been initialized, disconnecting it in the error
> path results in a NULL pointer exception. Drop the phy_disconnect
> from the error path.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Hi Sascha

The fix looks correct, since the phy should be bound to the device in
the following dsa_slave_phy_setup() call.

I'm not sure if Neil also fixed this...

Anyway,

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

     Andrew



> ---
>  net/dsa/slave.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index 40b9ca7..91e3b2f 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -1194,7 +1194,6 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
>  	if (ret) {
>  		netdev_err(master, "error %d registering interface %s\n",
>  			   ret, slave_dev->name);
> -		phy_disconnect(p->phy);
>  		ds->ports[port] = NULL;
>  		free_netdev(slave_dev);
>  		return ret;
> -- 
> 2.7.0.rc3
>
Neil Armstrong Feb. 15, 2016, 8:52 a.m. UTC | #3
On 02/11/2016 04:39 PM, Vivien Didelot wrote:
> Hi Sascha,
> 
> Sascha Hauer <s.hauer@pengutronix.de> writes:
> 
>> The phy has not been initialized, disconnecting it in the error
>> path results in a NULL pointer exception. Drop the phy_disconnect
>> from the error path.
>>
>> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
>> ---
>>  net/dsa/slave.c | 1 -
>>  1 file changed, 1 deletion(-)
>>
>> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
>> index 40b9ca7..91e3b2f 100644
>> --- a/net/dsa/slave.c
>> +++ b/net/dsa/slave.c
>> @@ -1194,7 +1194,6 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
>>  	if (ret) {
>>  		netdev_err(master, "error %d registering interface %s\n",
>>  			   ret, slave_dev->name);
>> -		phy_disconnect(p->phy);
>>  		ds->ports[port] = NULL;
>>  		free_netdev(slave_dev);
>>  		return ret;
> 
> I'm adding Neil in the loop, since he did some work similar to this, if
> I'm not mistaken.
> 
> Thanks,
> -v
> 

He's right, the phy is not yet created in this error path.

Acked-by: Neil Armstrong <narmstrong@baylibre.com>

Thanks Vivien,
Neil
David Miller Feb. 16, 2016, 9:05 p.m. UTC | #4
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Thu, 11 Feb 2016 11:44:49 +0100

> The phy has not been initialized, disconnecting it in the error
> path results in a NULL pointer exception. Drop the phy_disconnect
> from the error path.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Applied.
diff mbox

Patch

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 40b9ca7..91e3b2f 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1194,7 +1194,6 @@  int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
 	if (ret) {
 		netdev_err(master, "error %d registering interface %s\n",
 			   ret, slave_dev->name);
-		phy_disconnect(p->phy);
 		ds->ports[port] = NULL;
 		free_netdev(slave_dev);
 		return ret;