From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757140AbbJ2OGo (ORCPT ); Thu, 29 Oct 2015 10:06:44 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:36589 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751447AbbJ2OGm (ORCPT ); Thu, 29 Oct 2015 10:06:42 -0400 Subject: Re: [PATCH v2 5/6] net: dsa: add missing calls in dsa_switch_destroy To: Andrew Lunn References: <56321DCD.3070702@baylibre.com> <20151029140058.GS2307@lunn.ch> 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 From: Neil Armstrong Organization: Baylibre Message-ID: <563227EB.10708@baylibre.com> Date: Thu, 29 Oct 2015 15:06:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20151029140058.GS2307@lunn.ch> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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