[PATCH] fib_semantics: Fix warning in fib_check_nh_v4_gw

From: Vincenzo Frascino
Date: Mon Jun 17 2019 - 06:26:26 EST


Currently, the err variable in fib_check_nh_v4_gw may be used
uninitialized leading to the warning below:

fib_semantics.c: In function âfib_check_nh_v4_gwâ:
fib_semantics.c:1023:12: warning: âerrâ may be used
uninitialised in this function [-Wmaybe-uninitialized]
if (!tbl || err) {
^~

Initialize err to 0 to fix the warning.

Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
Cc: Alexey Kuznetsov <kuznet@xxxxxxxxxxxxx>
Cc: Hideaki YOSHIFUJI <yoshfuji@xxxxxxxxxxxxxx>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@xxxxxxx>
---
net/ipv4/fib_semantics.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index b80410673915..bfa49a88d03a 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -964,7 +964,7 @@ static int fib_check_nh_v4_gw(struct net *net, struct fib_nh *nh, u32 table,
{
struct net_device *dev;
struct fib_result res;
- int err;
+ int err = 0;

if (nh->fib_nh_flags & RTNH_F_ONLINK) {
unsigned int addr_type;
--
2.21.0