From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757200AbbJ2OBL (ORCPT ); Thu, 29 Oct 2015 10:01:11 -0400 Received: from vps0.lunn.ch ([178.209.37.122]:58134 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757177AbbJ2OBJ (ORCPT ); Thu, 29 Oct 2015 10:01:09 -0400 Date: Thu, 29 Oct 2015 15:00:58 +0100 From: Andrew Lunn To: Neil Armstrong Cc: "David S. Miller" , Florian Fainelli , Guenter Roeck , vivien.didelot@savoirfairelinux.com, Fabian Frederick , Pavel Nakonechny , Joe Perches , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Frode Isaksen Subject: Re: [PATCH v2 5/6] net: dsa: add missing calls in dsa_switch_destroy Message-ID: <20151029140058.GS2307@lunn.ch> References: <56321DCD.3070702@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56321DCD.3070702@baylibre.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Signed-off-by: Neil Armstrong > --- > 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