Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1739671imm; Fri, 6 Jul 2018 05:46:46 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd60G2hDeg4FzI03yfO9h1cCwSdTflLTNPSqtTI2Xja079P8wqPe3VtXv74PEhP5lZOkGM9 X-Received: by 2002:a17:902:4203:: with SMTP id g3-v6mr10003075pld.315.1530881206266; Fri, 06 Jul 2018 05:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530881206; cv=none; d=google.com; s=arc-20160816; b=NS956X99TP75aH6yw845v1+sKFSXBQ1h49thdMHM6dK8jSjD+gyazsNHsZN48bYfVV t6hL66EKv3XqGuhCPjMsKQdz//zchjj+fcWXpgzL2AHdL0fwOjGQbetaGnZ2vN1ehwFv Ed6dZMOHTbpfPemHqZfzqIQA9pxfgZ1CkpdNqT7d3U9gqK8Zq0Y4JaiC907lUzEna7eh ukopItvxf8rPW4aiI707Qn0L3Kpe9Zh6LwSHx6Z0cJyQIze+6RdBL3bq+a/gLKIpGcxk 9vRf0xZI3aMPLHmGwbiZvc+NKVKi0QwEWDdpKUmJYWN5cA0ksXV3e7zS+KXTo2GtcGHd RILg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=EJpS3fqzpeaoC6AjEdGyYmuTd547ZUwAtSNYzb83r8E=; b=Mt1DJf8Mn0G3//SpHZKnrZvK7RR3osCEKNnTQu06q/3UNlzznvyT9BpRcarXhTDn4i 3/NUu0KS97yUV7KChfFOeTANv4mzuoeP5bcBNzw6r/9WH79/YCaJ6oeoDD06UO4pR6oQ GEsrMEUfoZ5wrerNrMHYk/+zQyrV+ZaXXH65tNcbo1onkKVP4nPBCnlTLNu88FuqQLyc TelGmDMsWcdir9bITW4b/dOKRyTCdHpjIrerSAfd/KCUZ+WD4xgtYRDOQCoyBIdPDJDU efhsoBCzzK6SM+BRZQrd/VFYdykElZWNMiwP4doQ4URqbagFWLWBkE2l5qI2MS1F7qcV OYrg== 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 h16-v6si8033253pgb.39.2018.07.06.05.46.31; Fri, 06 Jul 2018 05:46:46 -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 S933182AbeGFMpH (ORCPT + 99 others); Fri, 6 Jul 2018 08:45:07 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:36435 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932780AbeGFMpF (ORCPT ); Fri, 6 Jul 2018 08:45:05 -0400 Received: from wuerfel.lan ([46.223.138.35]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0MTNxP-1fiBrS3g7b-00SOTF; Fri, 06 Jul 2018 14:44:57 +0200 From: Arnd Bergmann To: Jiri Pirko , Ido Schimmel , "David S. Miller" Cc: Arnd Bergmann , Petr Machata , Arkadi Sharshevsky , David Ahern , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next] mlxsw: spectrum_router: avoid uninitialized variable access Date: Fri, 6 Jul 2018 14:44:45 +0200 Message-Id: <20180706124455.3151925-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:J7FO4Mufy6+xtNO9NwawvR7wJtxPnR2HAlVOmO9WKZzguHHJ/dV a5hvDI9opJZ63nthBSYwE+1Bko3C+1RWCInXBSAz4QOITI43T/oSYyabg64Zqr/eZlHAv7K eVSGegKQXNtstTMqaX4mtpXJT70TOETl6GW2kP6hwpvy+cX+24H06MdSBwqO8p6fMVyeQ1r nRRt40H2i6EfhEMdXVmnQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:iGqPCEbja1E=:1ZV3SzDRIuW3YylSWgj9o8 AgUG6QGvDe/UeSDkBec+xrSro/bkWwy4VQeGqwQSoSudFOrPgOkvSHA9oP2ApUz5zx6vIsXMi YgPXEPuEgxRXev6ZMlzfvuLkLVVh1rqDUqp/2mXXkAdjsk/nemK4Jzl05YA+xV54bKYcLce/J 8S05HXsbZdLrdRxNqROoazmB4fhrUP/LLaY6ouJm9O2B0cmFrLOv7mbqS72m7ODuo5GJ5q5lk gB0H7J6MUt+L4IGXCev1QYAFWwMxe2mATS7pePswM3ypR3fDRcq7Tdvzsblk4h20n0+fhlB+U xI1bJCo8nAY8mc1a6G2l4ZFUeBBbQF72yM5UV3mNgKrv9EBxiFV+WG3JUaw6fuRJ3NVNIxcVT TczhC+m5Cbiol9KAz8qUNXmHsoepp8BYSPWCwrlECGkU3ue61pzVTXGFk+YZf2WyriTT6sH8W OWnuSEsLG9iA2Uvy+dE+dxVpaiPlVpqtf3D/lG1pfKkbKjgiQfrYpwkzIvPMTydqm/7o+YpLK BuF0V4dxYrd3qvXC7ADilkmljrZg0vjfH8iXKEMTISQrY5wlqDUOgZZ9ZZr+odcxvx7VKxrmJ fPXzxXehU/TYrmjNR5niZA/G5Hm0PKEuP/cn4oEy+pyRUsL34+rEyShgViisHyY7jG2Oit6mf 7Yg3XFsiJdvhX4SmifMmlc72wsmOpTcqmKarKsxFp4SHJXunZJkpLpeld6hVe6ei7OZ0= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When CONFIG_BRIDGE_VLAN_FILTERING is disabled, gcc correctly points out that the 'vid' variable is uninitialized whenever br_vlan_get_pvid returns an error: drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c: In function 'mlxsw_sp_rif_vlan_fid_get': drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:6881:6: error: 'vid' may be used uninitialized in this function [-Werror=maybe-uninitialized] This changes the condition check to always return -EINVAL here, which I guess is what the author intended here. Fixes: e6f1960ae6c7 ("mlxsw: spectrum_router: Allocate FID according to PVID") Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 071428227b91..60c352ddd6fd 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -6878,11 +6878,9 @@ mlxsw_sp_rif_vlan_fid_get(struct mlxsw_sp_rif *rif, vid = vlan_dev_vlan_id(rif->dev); } else { err = br_vlan_get_pvid(rif->dev, &vid); - if (!vid) - err = -EINVAL; - if (err) { + if (err < 0 || !vid) { NL_SET_ERR_MSG_MOD(extack, "Couldn't determine bridge PVID"); - return ERR_PTR(err); + return ERR_PTR(-EINVAL); } } -- 2.9.0