Thread (7 messages) 7 messages, 4 authors, 2016-10-03

Re: [PATCH 2/2] mlxsw: spectrum_router: avoid potential uninitialized data usage

From: Ido Schimmel <hidden>
Date: 2016-09-30 18:03:26
Also in: lkml

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 <arnd@arndb.de>
For net-next:
Acked-by: Ido Schimmel <redacted>

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!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help