netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 5/6] net: dsa: add missing calls in dsa_switch_destroy
@ 2015-10-29 13:23 Neil Armstrong
  2015-10-29 13:44 ` kbuild test robot
  2015-10-29 14:00 ` Andrew Lunn
  0 siblings, 2 replies; 4+ messages in thread
From: Neil Armstrong @ 2015-10-29 13:23 UTC (permalink / raw)
  To: David S. Miller
  Cc: Andrew Lunn, Florian Fainelli, Guenter Roeck, vivien.didelot,
	Fabian Frederick, Pavel Nakonechny, Joe Perches, netdev,
	linux-kernel, Frode Isaksen

Add missing netif_carrier_off and phy_disconnect calls to the
dsa_switch_destroy function to make sure the netdev and phy
ressources are clean before complete removal.

Signed-off-by: Frode Isaksen <fisaksen@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 net/dsa/dsa.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 597a462..11452e4 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -454,7 +454,9 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
 		if (!ds->ports[port])
 			continue;

+		netif_carrier_off(ds->ports[port]);
 		unregister_netdev(ds->ports[port]);
+		phy_disconnect(p->phy);
 		free_netdev(ds->ports[port]);
 	}

-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 5/6] net: dsa: add missing calls in dsa_switch_destroy
  2015-10-29 13:23 [PATCH v2 5/6] net: dsa: add missing calls in dsa_switch_destroy Neil Armstrong
@ 2015-10-29 13:44 ` kbuild test robot
  2015-10-29 14:00 ` Andrew Lunn
  1 sibling, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2015-10-29 13:44 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: kbuild-all, David S. Miller, Andrew Lunn, Florian Fainelli,
	Guenter Roeck, vivien.didelot, Fabian Frederick, Pavel Nakonechny,
	Joe Perches, netdev, linux-kernel, Frode Isaksen

[-- Attachment #1: Type: text/plain, Size: 1350 bytes --]

Hi Neil,

[auto build test ERROR on net/master -- if it's inappropriate base, please suggest rules for selecting the more suitable base]

url:    https://github.com/0day-ci/linux/commits/Neil-Armstrong/Further-fix-for-dsa-unbinding/20151029-212633
config: x86_64-randconfig-x010-201543 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

Note: the linux-review/Neil-Armstrong/Further-fix-for-dsa-unbinding/20151029-212633 HEAD 3c957c00de125eeffe9f50eda7cf94a98855f615 builds fine.
      It only hurts bisectibility.

All errors (new ones prefixed by >>):

   net/dsa/dsa.c: In function 'dsa_switch_destroy':
>> net/dsa/dsa.c:459:18: error: 'p' undeclared (first use in this function)
      phy_disconnect(p->phy);
                     ^
   net/dsa/dsa.c:459:18: note: each undeclared identifier is reported only once for each function it appears in

vim +/p +459 net/dsa/dsa.c

   453	
   454			if (!ds->ports[port])
   455				continue;
   456	
   457			netif_carrier_off(ds->ports[port]);
   458			unregister_netdev(ds->ports[port]);
 > 459			phy_disconnect(p->phy);
   460			free_netdev(ds->ports[port]);
   461		}
   462	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 28624 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 5/6] net: dsa: add missing calls in dsa_switch_destroy
  2015-10-29 13:23 [PATCH v2 5/6] net: dsa: add missing calls in dsa_switch_destroy Neil Armstrong
  2015-10-29 13:44 ` kbuild test robot
@ 2015-10-29 14:00 ` Andrew Lunn
  2015-10-29 14:06   ` Neil Armstrong
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2015-10-29 14:00 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: David S. Miller, Florian Fainelli, Guenter Roeck, vivien.didelot,
	Fabian Frederick, Pavel Nakonechny, Joe Perches, netdev,
	linux-kernel, Frode Isaksen

On Thu, Oct 29, 2015 at 02:23:25PM +0100, Neil Armstrong wrote:
> Add missing netif_carrier_off and phy_disconnect calls to the
> dsa_switch_destroy function to make sure the netdev and phy
> ressources are clean before complete removal.
> 
> Signed-off-by: Frode Isaksen <fisaksen@baylibre.com>
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>  net/dsa/dsa.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
> index 597a462..11452e4 100644
> --- a/net/dsa/dsa.c
> +++ b/net/dsa/dsa.c
> @@ -454,7 +454,9 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
>  		if (!ds->ports[port])
>  			continue;
> 
> +		netif_carrier_off(ds->ports[port]);
>  		unregister_netdev(ds->ports[port]);
> +		phy_disconnect(p->phy);
>  		free_netdev(ds->ports[port]);
>  	}

Once you make it actually compile....

I'm not sure this is safe. The loop above this one has just destroyed
some phys, and now you are potentially disconnecting a phy you just
destroyed, causing it to be accessed?

I would suggest you first fix the ordering in dsa_switch_destroy()
and then add the missing netif_carrier_off() and phy_disconnect().

Thanks
	Andrew

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 5/6] net: dsa: add missing calls in dsa_switch_destroy
  2015-10-29 14:00 ` Andrew Lunn
@ 2015-10-29 14:06   ` Neil Armstrong
  0 siblings, 0 replies; 4+ messages in thread
From: Neil Armstrong @ 2015-10-29 14:06 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: David S. Miller, Florian Fainelli, Guenter Roeck, vivien.didelot,
	Fabian Frederick, Pavel Nakonechny, Joe Perches, netdev,
	linux-kernel, Frode Isaksen

On 10/29/2015 03:00 PM, Andrew Lunn wrote:
> On Thu, Oct 29, 2015 at 02:23:25PM +0100, Neil Armstrong wrote:
>>
>> +		netif_carrier_off(ds->ports[port]);
>>  		unregister_netdev(ds->ports[port]);
>> +		phy_disconnect(p->phy);
>>  		free_netdev(ds->ports[port]);
>>  	}
> 
> Once you make it actually compile....
> 
> I'm not sure this is safe. The loop above this one has just destroyed
> some phys, and now you are potentially disconnecting a phy you just
> destroyed, causing it to be accessed?
> 
> I would suggest you first fix the ordering in dsa_switch_destroy()
> and then add the missing netif_carrier_off() and phy_disconnect().
> 
> Thanks
> 	Andrew
> 

Yes, you are right, I will submit a cleaned up version.
I forgot the fixed phy case actually.

Thanks,
Neil

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-29 14:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-29 13:23 [PATCH v2 5/6] net: dsa: add missing calls in dsa_switch_destroy Neil Armstrong
2015-10-29 13:44 ` kbuild test robot
2015-10-29 14:00 ` Andrew Lunn
2015-10-29 14:06   ` Neil Armstrong

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).