Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3990487ybz; Mon, 4 May 2020 13:36:10 -0700 (PDT) X-Google-Smtp-Source: APiQypK9TsYNHKHmSlKc9AplSBJKHVxx4617YfwRxXEgCm7i//OrhdxlIDQdM4u1B8EKBZ6nqP4z X-Received: by 2002:a17:906:9706:: with SMTP id k6mr17108665ejx.103.1588624570354; Mon, 04 May 2020 13:36:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588624570; cv=none; d=google.com; s=arc-20160816; b=XQCq/lSIvMtPNH0V2gWnpa6a9AosjvgFQg17/rFMy7gkS5WT54IIb78oEJ/f2OuA4w wEPjoXfDUAtQjPSlXsqWM2jw8htr5q7NWkimd32lOqWVmtLwDkqLJX3esgQZ+IsFRSmI 61WwciutGzp2/KsHfK9jWFp8KsdzazBzUudqdLfnjUNZvy3sCotn7xbbtRQutgT2AdQ3 OOirEMXK5XTlhXJ+eLVKrUKBs1hU4U9kZMw4kk5cC4K+L02O3Sz2Vc0teaX9k5tapZaE 9PT+Oo9N6XZhCjKkXMxYx9wKWF6AXsqvkETa6iakgvIh0Dh5VmkwBUiwXOBqTj/DG7RH Wcjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=0ujQBkedTruUaYli8xYvaDmOGg+LHDXWsK2ccHcdSVw=; b=IjlAR/QPXsK0egGz3AlxRga5rQ6dbtJt3klSeJvvHx0MpXKbtau8nA8T2/V9w6WDg1 zNuFZ5lJeyLdhEfUXU0WjeayLVNKF+5Mq6QOTMTxbbQlp6PDqOPUhO4ymbVchyOmdMFs retfO43yIhAtzndMVm7xnme1yBlTt4c/Tw4sTv8r4v1EKKijCnL51jtOhu+WAZzTw+U+ 8/rFisQN2EuefgySxoAqTuYqzlP6jdsC/75Qewbt2je21tKUkc4z02gjnsNjo01rOlBM 8wef7GTQfbAlSuIcRX4ge0A7acgxrL5Zx8B6uaAAh0Qdp/p0Tx/crEDUvWJcKXpUDoYR BpXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IBszTMXc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ly2si7284958ejb.95.2020.05.04.13.35.45; Mon, 04 May 2020 13:36:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IBszTMXc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727838AbgEDUeQ (ORCPT + 99 others); Mon, 4 May 2020 16:34:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726334AbgEDUeP (ORCPT ); Mon, 4 May 2020 16:34:15 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B51AC061A0E; Mon, 4 May 2020 13:34:15 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id t12so14782124edw.3; Mon, 04 May 2020 13:34:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0ujQBkedTruUaYli8xYvaDmOGg+LHDXWsK2ccHcdSVw=; b=IBszTMXczFe5F/fu85oU0ycVzvAlEnxq50EH4Wp9Euc4Zb2L47c3tvalIDRU0jiNDu h3+ksOL0GZW95hQlGBKTs4mmKe8KVvzVkN4qoCy+A1i12umkFk0Vglp/SWNg7ZtS0faU coEoWU7Q05dsezdat1dFMLP0m8gEuo1o+hBg1rvFITg3ruBTu7HYQGpVyqUXU4OgNQBk PZZyCrgkWpM/uWM7CpKZgtiEl2Ek1j1jAsi5sk/8d2KTQ4YOBuTNw5B/0wEOLwMnRWne hadnqjW3MocrscbVh4ak9VJ/R9HBqFAJuMubsBnwv6R3NtgMfx2V06D4aWnwmJJeounJ SBfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0ujQBkedTruUaYli8xYvaDmOGg+LHDXWsK2ccHcdSVw=; b=Fb6tr2Xm8h64VpWNMY/6c209JufZkQkiu43tEiY+1XX3CroLZm4hWylSute/MoVoDU t5IcecbKPCrhWU6NLbbmBmtkdkbpKxhtcsb805CqTUgP1RDwv0OjOLrtixj+R9hswOpV go4ArFB1mkVVWax1PSk7EuYCU5BsHTymZN1jw/d9nDDjmEwhp0MDM7RdGk4TLBlAwT0E u58Xau1LXEAwRHHaJkcrk+aISFov9Bu/QSeAT17XrIa3gsu7Nekjf9XP8xGyiRKugf/Y CgL70I6P0JxZhBB5QC69DDPpCqOlUMjmWN8ebs3gMCK0i0QxrmGTAu4g95jBpYrL71Dc M7Sg== X-Gm-Message-State: AGi0PuY5LapGbwxNEtGAOJhyzf5j7+K3PaF6Es3wmH/eRHhlydQzpi4x aD3HDQLOSjYONQttUTl8iVcKwoU62WztA5evM5k= X-Received: by 2002:a50:a2e5:: with SMTP id 92mr16631358edm.139.1588624453705; Mon, 04 May 2020 13:34:13 -0700 (PDT) MIME-Version: 1.0 References: <20200504201806.27192-1-f.fainelli@gmail.com> In-Reply-To: <20200504201806.27192-1-f.fainelli@gmail.com> From: Vladimir Oltean Date: Mon, 4 May 2020 23:34:02 +0300 Message-ID: Subject: Re: [PATCH net] net: dsa: Do not leave DSA master with NULL netdev_ops To: Florian Fainelli Cc: netdev , allen.pais@oracle.com, Andrew Lunn , Vivien Didelot , "David S. Miller" , Jakub Kicinski , open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Florian, On Mon, 4 May 2020 at 23:19, Florian Fainelli wrote: > > When ndo_get_phys_port_name() for the CPU port was added we introduced > an early check for when the DSA master network device in > dsa_master_ndo_setup() already implements ndo_get_phys_port_name(). When > we perform the teardown operation in dsa_master_ndo_teardown() we would > not be checking that cpu_dp->orig_ndo_ops was successfully allocated and > non-NULL initialized. > > With network device drivers such as virtio_net, this leads to a NPD as > soon as the DSA switch hanging off of it gets torn down because we are > now assigning the virtio_net device's netdev_ops a NULL pointer. > > Fixes: da7b9e9b00d4 ("net: dsa: Add ndo_get_phys_port_name() for CPU port") > Reported-by: Allen Pais > Signed-off-by: Florian Fainelli > --- The fix makes complete sense. But on another note, if we don't overlay an ndo_get_phys_port_name if the master already has one, doesn't that render the entire mechanism of having a reliable way for user space to determine the CPU port number pointless? > net/dsa/master.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/net/dsa/master.c b/net/dsa/master.c > index b5c535af63a3..a621367c6e8c 100644 > --- a/net/dsa/master.c > +++ b/net/dsa/master.c > @@ -289,7 +289,8 @@ static void dsa_master_ndo_teardown(struct net_device *dev) > { > struct dsa_port *cpu_dp = dev->dsa_ptr; > > - dev->netdev_ops = cpu_dp->orig_ndo_ops; > + if (cpu_dp->orig_ndo_ops) > + dev->netdev_ops = cpu_dp->orig_ndo_ops; > cpu_dp->orig_ndo_ops = NULL; > } > > -- > 2.20.1 > Regards, -Vladimir