Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1159251imm; Wed, 1 Aug 2018 11:09:36 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfsiziC7km4km4pPro6wTa8Sbg0GdQkOIqNAQLyBcGq5mC/oYV84/MMEdq03EtTnka9vUh3 X-Received: by 2002:a17:902:301:: with SMTP id 1-v6mr25470307pld.127.1533146975969; Wed, 01 Aug 2018 11:09:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533146975; cv=none; d=google.com; s=arc-20160816; b=vq0yjQIvO6UbejyhuRoMJ5adECvygIVIvzOXOwjBPXTlnzyNE+WysicI7fEPddbWOG vTTibkYRcuQKDcTuME5Hc/kgz3ElXVgaIQXP52Q3eiOa8i8qkVylaofAwGsKBW38oiMq NMXmA/8ZDpYvugcZzv6Kl99/cQ1NOdfVHjC+pw2jQ8JTzmg5MhL/a8v8n0fja4RaE5Xl pH1OAHZSemIHpsqdDmc22xuGq4NRvptJrG4P9yivAzeYNAU7gNPo+W+iK3DNSTeqdiOI fVTC+5Lgp+ZLxAM2N8KZcNKDOO7NzzjzP752RMkaZrN0/A2OrtZ0EgSTTojZNpnSFEq2 eYfQ== 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 :arc-authentication-results; bh=/aOheLR7oU+EiWgGPyXg+i6Ftav+GHC8MI5PgTZszXY=; b=cYyAIgbzqEPM9Lon3JOUqviUl2+/PbWhCrkg3Cgn6yQleHEQ5MSJEg/BVU+TKAdBne dQLiV89QgSo7xA87DzIKRCrLPhxVgXwqZeWYYydyYZDlleok1Gg5SeW1NiwVO+hjB+w0 KgOuUmFZB33tjik3YvK/i2ZLxbkVWmnKJeoT0HPvgDyf9r7xk7pxM6PPZFEdj9JP1thL +e/LaCXZVbBElOybVifRIboXiLlZCyfzp29QoHWpB4Wu7xh/aQ88sA90L1absIanGMrk XdIXq9oF6yOePpb8197s8v6MICYAoqfAtmV7pkH6AkJCyV783rhdENvurFv31vG6p24x bYHQ== ARC-Authentication-Results: i=1; mx.google.com; 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 y22-v6si16937794pgj.436.2018.08.01.11.09.21; Wed, 01 Aug 2018 11:09:35 -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; 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 S1732398AbeHATyz (ORCPT + 99 others); Wed, 1 Aug 2018 15:54:55 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50120 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405020AbeHATIg (ORCPT ); Wed, 1 Aug 2018 15:08:36 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6FA8F1395; Wed, 1 Aug 2018 17:15:15 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Petr Machata , Jiri Pirko , Ido Schimmel , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 019/246] mlxsw: spectrum_switchdev: Fix port_vlan refcounting Date: Wed, 1 Aug 2018 18:48:49 +0200 Message-Id: <20180801165012.627922023@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Petr Machata [ Upstream commit 9e25826ffc942e985b8595b2f1cf2065d3880514 ] Switchdev notifications for addition of SWITCHDEV_OBJ_ID_PORT_VLAN are distributed not only on clean addition, but also when flags on an existing VLAN are changed. mlxsw_sp_bridge_port_vlan_add() calls mlxsw_sp_port_vlan_get() to get at the port_vlan in question, which implicitly references the object. This then leads to discrepancies in reference counting when the VLAN is removed. spectrum.c warns about the problem when the module is removed: [13578.493090] WARNING: CPU: 0 PID: 2454 at drivers/net/ethernet/mellanox/mlxsw/spectrum.c:2973 mlxsw_sp_port_remove+0xfd/0x110 [mlxsw_spectrum] [...] [13578.627106] Call Trace: [13578.629617] mlxsw_sp_fini+0x2a/0xe0 [mlxsw_spectrum] [13578.634748] mlxsw_core_bus_device_unregister+0x3e/0x130 [mlxsw_core] [13578.641290] mlxsw_pci_remove+0x13/0x40 [mlxsw_pci] [13578.646238] pci_device_remove+0x31/0xb0 [13578.650244] device_release_driver_internal+0x14f/0x220 [13578.655562] driver_detach+0x32/0x70 [13578.659183] bus_remove_driver+0x47/0xa0 [13578.663134] pci_unregister_driver+0x1e/0x80 [13578.667486] mlxsw_sp_module_exit+0xc/0x3fa [mlxsw_spectrum] [13578.673207] __x64_sys_delete_module+0x13b/0x1e0 [13578.677888] ? exit_to_usermode_loop+0x78/0x80 [13578.682374] do_syscall_64+0x39/0xe0 [13578.685976] entry_SYSCALL_64_after_hwframe+0x44/0xa9 Fix by putting the port_vlan when mlxsw_sp_port_vlan_bridge_join() determines it's a flag-only change. Fixes: b3529af6bb0d ("spectrum: Reference count VLAN entries") Signed-off-by: Petr Machata Acked-by: Jiri Pirko Signed-off-by: Ido Schimmel Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c @@ -912,8 +912,10 @@ mlxsw_sp_port_vlan_bridge_join(struct ml int err; /* No need to continue if only VLAN flags were changed */ - if (mlxsw_sp_port_vlan->bridge_port) + if (mlxsw_sp_port_vlan->bridge_port) { + mlxsw_sp_port_vlan_put(mlxsw_sp_port_vlan); return 0; + } err = mlxsw_sp_port_vlan_fid_join(mlxsw_sp_port_vlan, bridge_port); if (err)