From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750905AbdAXR4o (ORCPT ); Tue, 24 Jan 2017 12:56:44 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:34349 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750771AbdAXR4m (ORCPT ); Tue, 24 Jan 2017 12:56:42 -0500 Subject: Re: [PATCH net] net: dsa: Keep a reference count on ethernet_dev To: David Miller References: <20170121174055.27560-1-f.fainelli@gmail.com> <20170124.123911.330293119907498159.davem@davemloft.net> Cc: netdev@vger.kernel.org, andrew@lunn.ch, vivien.didelot@savoirfairelinux.com, linux-kernel@vger.kernel.org From: Florian Fainelli Message-ID: Date: Tue, 24 Jan 2017 09:56:39 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20170124.123911.330293119907498159.davem@davemloft.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/24/2017 09:39 AM, David Miller wrote: > From: Florian Fainelli > Date: Sat, 21 Jan 2017 09:40:54 -0800 > >> of_find_net_device_by_node() just returns a reference to a net_device but does >> not increment its reference count, which means that the master network device >> can just vanish under our feet. >> >> Fixes: 83c0afaec7b7 ("net: dsa: Add new binding implementation") >> Signed-off-by: Florian Fainelli > > This is fine, except now this netdev is completely locked into place with > no way to dynamically unload it. > > If someone tries to modunload the driver for this ethernet device, > their screen will fill up with warning messages indicating that the > reference taken here in the DSA code is not going away. > > You need to implement a netdev notifier that tears down this DSA > instance during an unregister event and releases the ethernet_dev. > Similar to how we handle protocol addresses bound to a netdev, etc. OK, that was actually my original approach, and then while detaching the switch from the network device seemed easy enough, re-attaching it could be a little challenging. Let's try again. Thanks! -- Florian