Skip to content

Commit 6f19955

Browse files
w1ldptrdavem330
authored andcommitted
net: fib_notifier: don't return positive values on fib registration
The function fib6_walk_continue() cannot return a positive value when called from register_fib_notifier(), but ignoring causes static analyzer to generate warnings in users of register_fib_notifier() that try to convert returned error code to pointer with ERR_PTR(). Handle such case by explicitly checking for positive error values and converting them to -EINVAL in fib6_tables_dump(). Reported-by: Dan Carpenter <[email protected]> Suggested-by: Ido Schimmel <[email protected]> Signed-off-by: Vlad Buslov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9f1b0df commit 6f19955

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/ipv6/ip6_fib.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,15 +499,16 @@ int fib6_tables_dump(struct net *net, struct notifier_block *nb,
499499

500500
hlist_for_each_entry_rcu(tb, head, tb6_hlist) {
501501
err = fib6_table_dump(net, tb, w);
502-
if (err < 0)
502+
if (err)
503503
goto out;
504504
}
505505
}
506506

507507
out:
508508
kfree(w);
509509

510-
return err;
510+
/* The tree traversal function should never return a positive value. */
511+
return err > 0 ? -EINVAL : err;
511512
}
512513

513514
static int fib6_dump_node(struct fib6_walker *w)

0 commit comments

Comments
 (0)