From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933633AbcI3SD0 (ORCPT ); Fri, 30 Sep 2016 14:03:26 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:53489 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933150AbcI3SDQ (ORCPT ); Fri, 30 Sep 2016 14:03:16 -0400 X-Greylist: delayed 372 seconds by postgrey-1.27 at vger.kernel.org; Fri, 30 Sep 2016 14:03:16 EDT X-Sasl-enc: fZTaiY/lBnYxEFuSgzaJCkNgngMXN1XcFVgf71L4nmGR 1475258222 Date: Fri, 30 Sep 2016 20:57:00 +0300 From: Ido Schimmel To: Arnd Bergmann Cc: Jiri Pirko , Ido Schimmel , "David S. Miller" , Yotam Gigi , Nogah Frankel , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] mlxsw: spectrum_router: avoid potential uninitialized data usage Message-ID: <20160930175700.GA641@splinter> References: <20160930161734.70928-1-arnd@arndb.de> <20160930161734.70928-2-arnd@arndb.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160930161734.70928-2-arnd@arndb.de> User-Agent: Mutt/1.7.0 (2016-08-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 30, 2016 at 06:17:10PM +0200, Arnd Bergmann wrote: > 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 For net-next: Acked-by: Ido Schimmel BTW, which flags did you pass to generate this error? I can only reproduce this with EXTRA_CFLAGS="-Wmaybe-uninitialized -Werror", but for some reason EXTRA_CFLAGS="-Wall -Werror" is silent. Any idea why? I would like to add this to my git hooks and avoid these errors in the future :) Thanks!