Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1962367imm; Thu, 24 May 2018 03:39:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrTFKrIg0EzLQ/YRAGT10Z0HUylrQY6jkLOSVa0RP1+J6dXnjYTbXaOvMxbqF87W0BycBc9 X-Received: by 2002:a63:6e8e:: with SMTP id j136-v6mr5502215pgc.450.1527158397454; Thu, 24 May 2018 03:39:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527158397; cv=none; d=google.com; s=arc-20160816; b=CFiVdtNnve8aaUNRm6qhFg9Baxteo5DVZoasITCqg3nanQkwk7+NNaBsGgyYPOO+a/ nsWCCjdoJ7dHanG/ZINQpJ2ACdYZMqaW2L6VA36CWchp9jjcgIt2KzQenAXK2+wme6L7 JWuOJQ9gjzM4Dl9oGKnS96i7LbBJR4gCY/cg81iVQmsws1penaler59RVKSVkgzd+znb zUouovzaNOXJFaZcl3eEExTbmC5N/+jh3Muw8/TOUfxV2dpIiKi87IvhGCysl8zgbIIU rrEoDvcq3Ymq2da/cfA3B5TOZTW3leel9oVBxqfSK99Pk6GmSpPwLENtdjZW4qELrrkh zb3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=cxOpGOv09RLngUqSqrS+zltCBkg24+TamwgfmSRi9+c=; b=LBCMmo42i1ICwyvWJIIKUQNB8PTmw8xQw7+NSIMa+o7PFUqM8OGZxYfGpzj2/Jw3Sx 9ESciI+hMutXIERFQaSk5VoQ7Q6+jRC6aZ5SSRHNrj+Ce5+sNIVA0WIFEO6I4ocgPDl5 UlBq11++RC1q02ncjx365hapxjOV4+htySS4GXx5bPQg6+DYrxg/alRemo2JEUC2tfrE VlQIHUBF9mU6MKVXU2K5CWv1Qu/V3KDoPE4haVakS8xkOUUOruO1p/d4vwdCjAPEognN suTduIxQdu02vPkz2O1U53LsidPNUWs3pVtBZ9Eyokc/MKWIpi/4FZ/jUz1gitwBld2d +NCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XXlKQTHB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 202-v6si16751975pgg.546.2018.05.24.03.39.42; Thu, 24 May 2018 03:39:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XXlKQTHB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032224AbeEXKjG (ORCPT + 99 others); Thu, 24 May 2018 06:39:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:40268 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030753AbeEXJ7X (ORCPT ); Thu, 24 May 2018 05:59:23 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A18B52088E; Thu, 24 May 2018 09:59:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155963; bh=OsHf4C7EhDFYfk8TYarsJeNNRcv2cBv6t51Rxpou5fs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XXlKQTHBnCIFIdx4USf0iQdbz2clzyd+2PdBwr6XaqZSkjTAYtJdyAvPGKtS2O4ve 5Ryfd5MhNhVmU/gkjlCBI2wpqhbLk6/9BB9hY51FcVCViMiv/PGxYOS8/qG4FlFQll 2L8bL1eCHDw8t2UdNZg7lddBGHijZQZt3WyTStZc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiri Pirko , Florian Fainelli , "David S. Miller" Subject: [PATCH 4.16 015/161] net: dsa: Do not register devlink for unused ports Date: Thu, 24 May 2018 11:37:20 +0200 Message-Id: <20180524093020.211729785@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Florian Fainelli [ Upstream commit 5447d78623da2eded06d4cd9469d1a71eba43bc4 ] Even if commit 1d27732f411d ("net: dsa: setup and teardown ports") indicated that registering a devlink instance for unused ports is not a problem, and this is true, this can be confusing nonetheless, so let's not do it. Fixes: 1d27732f411d ("net: dsa: setup and teardown ports") Reported-by: Jiri Pirko Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/dsa/dsa2.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -258,11 +258,13 @@ static void dsa_tree_teardown_default_cp static int dsa_port_setup(struct dsa_port *dp) { struct dsa_switch *ds = dp->ds; - int err; + int err = 0; memset(&dp->devlink_port, 0, sizeof(dp->devlink_port)); - err = devlink_port_register(ds->devlink, &dp->devlink_port, dp->index); + if (dp->type != DSA_PORT_TYPE_UNUSED) + err = devlink_port_register(ds->devlink, &dp->devlink_port, + dp->index); if (err) return err; @@ -293,7 +295,8 @@ static int dsa_port_setup(struct dsa_por static void dsa_port_teardown(struct dsa_port *dp) { - devlink_port_unregister(&dp->devlink_port); + if (dp->type != DSA_PORT_TYPE_UNUSED) + devlink_port_unregister(&dp->devlink_port); switch (dp->type) { case DSA_PORT_TYPE_UNUSED: