From patchwork Fri Sep 30 16:17:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101723 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp378840qgf; Fri, 30 Sep 2016 09:17:51 -0700 (PDT) X-Received: by 10.66.230.228 with SMTP id tb4mr12878763pac.99.1475252271207; Fri, 30 Sep 2016 09:17:51 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bf12si20664448pac.239.2016.09.30.09.17.51; Fri, 30 Sep 2016 09:17:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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 netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934055AbcI3QRs (ORCPT + 4 others); Fri, 30 Sep 2016 12:17:48 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:58549 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933082AbcI3QRp (ORCPT ); Fri, 30 Sep 2016 12:17:45 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue102) with ESMTPA (Nemesis) id 0MhDFZ-1bd8UK0sYz-00MP0r; Fri, 30 Sep 2016 18:17:37 +0200 From: Arnd Bergmann To: Saeed Mahameed , Matan Barak , Leon Romanovsky Cc: Arnd Bergmann , "David S. Miller" , Or Gerlitz , Amir Vadai , Maor Gottlieb , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] net/mlx5e: shut up maybe-uninitialized warning Date: Fri, 30 Sep 2016 18:17:09 +0200 Message-Id: <20160930161734.70928-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:XG37sqmcQr1jXBBzmO3UjQIDNtxovSgWSAi2bjmjYx1vgquXkv1 G/Z1N5TFeGFr24zBwB6rqGZd8HPNxp9pOcuSCkDV94LRZN6lyw+jki1ialGEHA+UEErisUv pZyaR57473diVGKiLeOc6XjJybHN2YMNknFtbZ4ko/IkPO3ACJRw9myICS0SlJBmWq1m7Bb K5k+8avGHDQtue9TFjSkQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:fAz9jXfXee4=:LPBPQqSR+at0H+fQYBnvQa 4bktVz9882+6URwsUo+kbK97QGroxqdNz88bLDzYSxpmUeCbj69CktEc3TtOgJFJ2t6T74aBz 89+nCmqGUjEazUhJJGn+PtcECldeP+6OwjmTNcH3eixfiVUrDRja9LyaWzdxaSu4IbSjbIBna g5U/wOZ9v2joyvaWzi69kJzUYrwaDIIGof3Pa8wI0iRDf6186GLKpg8t+CNtNTqdKtEXO0G2Y 5TCmya1npBWIfV/TXAsTljFraFNf6R8yOPvKf7GOSIttWUTLzZLRAFbql3Uqxl1yzPijXq2Hb Si7ORHchaxion/ioREMs4IJ5V0qma3bnCd5j/NXNoCN45uG5ImWNwrcNl8F2tTfUO5RCOcDcV T1+QLsjehOncnKIP4su0xA+Av6I1S0b4h3Fhoo+oSg2gXkTgd7ri8CSMFDS1pNpOGkSm5nC5M dHNxVbNli8mclNJL9bExv31fUbNmFBHvTfYfiFwJMeEQKsOU6afAVHjVrIFl0yz6TaHRFWt90 Rbal/odjA+bJ0BEDKESose4tS6cMHfQNfpAs3tGzNU7L+DygLWIw6k1FWPTMgTv1U/uy5qkRE Npl6tmzhyfkKwSlls2Dq0sOOcZ6Lazd26DM1VmnLupnBNTmjup6NF1tjHDTGh9xroovusGSsU tmiUt5WbOjE2bY+DNJ9XczjJC406SfZZFG/Y1cJqEBQcaod2Mz84gLJLvWCPZlkTKdks= Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Build-testing this driver with -Wmaybe-uninitialized gives a new false-positive warning that I can't really explain: drivers/net/ethernet/mellanox/mlx5/core/en_tc.c: In function 'mlx5e_configure_flower': drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:509:3: error: 'old_attr' may be used uninitialized in this function [-Werror=maybe-uninitialized] It's obvious from the code that 'old_attr' is initialized whenever 'old' is non-NULL here. The warning appears with all versions I tested from gcc-4.7 through gcc-6.1, and I could not come up with a way to rewrite the function in a more readable way that avoids the warning, so I'm adding another initialization to shut it up. Fixes: 8b32580df1cb ("net/mlx5e: Add TC vlan action for SRIOV offloads") Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.0 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index a350b7171e3d..ce8c54d18906 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -451,7 +451,7 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv, __be16 protocol, struct mlx5e_tc_flow *flow; struct mlx5_flow_spec *spec; struct mlx5_flow_rule *old = NULL; - struct mlx5_esw_flow_attr *old_attr; + struct mlx5_esw_flow_attr *old_attr = NULL; struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; if (esw && esw->mode == SRIOV_OFFLOADS) From patchwork Fri Sep 30 16:17:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101722 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp379028qgf; Fri, 30 Sep 2016 09:18:15 -0700 (PDT) X-Received: by 10.98.41.131 with SMTP id p125mr13284395pfp.108.1475252295308; Fri, 30 Sep 2016 09:18:15 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u8si20661357paz.216.2016.09.30.09.18.15; Fri, 30 Sep 2016 09:18:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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 netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934174AbcI3QSF (ORCPT + 4 others); Fri, 30 Sep 2016 12:18:05 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:56240 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933082AbcI3QSA (ORCPT ); Fri, 30 Sep 2016 12:18:00 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue102) with ESMTPA (Nemesis) id 0MZUYX-1bVSzF1Yz7-00LHUL; Fri, 30 Sep 2016 18:17:52 +0200 From: Arnd Bergmann To: Jiri Pirko , Ido Schimmel Cc: Arnd Bergmann , "David S. Miller" , Yotam Gigi , Nogah Frankel , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] mlxsw: spectrum_router: avoid potential uninitialized data usage Date: Fri, 30 Sep 2016 18:17:10 +0200 Message-Id: <20160930161734.70928-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160930161734.70928-1-arnd@arndb.de> References: <20160930161734.70928-1-arnd@arndb.de> X-Provags-ID: V03:K0:fsg1HtqsQxpqRN8nXjTawOxa5rJrOLgeeyJuvE1NH0mj5gWHtb+ ONVmwNwATuY3CQfi8prE5Pfa6prmTvL/SStlcibMIxmfCf1tGVTIPo1dBJ3G6YYB3kLUpY/ 01g8sM9Dt2mJ4VmA+A3RvVN5n6l7TdpVe0QPnYbFQ/N3xrdU9m83N2ihwya0UwZhWa3flec gfNu4egqP5UcUqkGmW6BQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:hsvL8TpVDLo=:4KT7CPKJUah7WGIZhRqPaA t6SXw44kfPgEEfFO7NbhIysd4CFvmvjiIvFsHyQBnokNZMj058lknrucGOR6r+3KoKidlnZQc YjIWSOWfydCUeXNV1g00aTDoDBc4CPHwJXP1/DZYqmdp+/cDYhR9421OVVlUSM09L2PAbSf6d S1aFhX0YaiaA1T3xVvOou4wDMSe5ydR9wQCdZKV+Q05Cxor+1DvrUQd4WvGZw3xwECOzDR6Xj 0ALyN4k/kfvsUB9pwq1WEs3w4DaVk4RqqISnKIsVpowNCSZpzWHW6DFvPBO3atkJStQNIGktU XDMpcFeMbouXddenvkkHZQbbSz2ND3KrLOLGhfQWRxrJqFomdSH/aPGiQDjYJUjBXdVjafMc/ sBk75dFWfxUIpcQnlXmq2q8+wc9tPwUaUji+N65bYI1Euv/s69S1IsLvMwF5bOLp7ObTdj5pw 5L0PPVCivEUI/to35ZuJ4Nu0nixCytSeXlcjSG365x/m2YZ4jZJ6xmWHsG594rEe9UrxrRJfD mWgDnBPZB1nnIXrkGrdTTv+YEG2Dt+gZFQXS55j0uind1TdLNu08nRCJDkGzNP6H0IZdCM3Nf OeQrgQpCjl8BEarZLau8Xf6CKMWuumOOI176X4Ig3XZEH0XT5Yt8c3Ab1J6muUpfviHBslD8P 4WjFsAHfgaRwEsjQPkd9C7i0UcyOjC9bpvti4JrucKqZQpbCjofeEp1JCI1CHOJ+aY8c= Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If fi->fib_nhs is zero, the router interface pointer is uninitialized, as shown by this warning: drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c: In function 'mlxsw_sp_router_fib_event': drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:1674:21: error: 'r' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:1643:23: note: 'r' was declared here This changes the loop so we handle the case the same way as finding no router interface pointer attached to one of the nexthops to ensure we always trap here instead of using uninitialized data. Fixes: b45f64d16d45 ("mlxsw: spectrum_router: Use FIB notifications instead of switchdev calls") Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.9.0 diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 48d50efec5e2..78fc557d6dd7 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -1640,7 +1640,7 @@ mlxsw_sp_router_fib4_entry_init(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fib_entry *fib_entry) { struct fib_info *fi = fen_info->fi; - struct mlxsw_sp_rif *r; + struct mlxsw_sp_rif *r = NULL; int nhsel; int err; @@ -1664,11 +1664,15 @@ mlxsw_sp_router_fib4_entry_init(struct mlxsw_sp *mlxsw_sp, * to us. Set trap and pass the packets for * this prefix to kernel. */ - fib_entry->type = MLXSW_SP_FIB_ENTRY_TYPE_TRAP; - return 0; + break; } } + if (!r) { + fib_entry->type = MLXSW_SP_FIB_ENTRY_TYPE_TRAP; + return 0; + } + if (fi->fib_scope != RT_SCOPE_UNIVERSE) { fib_entry->type = MLXSW_SP_FIB_ENTRY_TYPE_LOCAL; fib_entry->rif = r->rif;