Skip to content

Commit

Permalink
netdev: remove potentially harmful checks
Browse files Browse the repository at this point in the history
Currently we're checking a variable for != NULL after actually
dereferencing it, in netdev_lower_get_next_private*().

It's counter-intuitive at best, and can lead to faulty usage (as it implies
that the variable can be NULL), so fix it by removing the useless checks.

Reported-by: Daniel Borkmann <dborkman@redhat.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Nicolas Dichtel <nicolas.dichtel@6wind.com>
CC: Jiri Pirko <jiri@resnulli.us>
CC: stephen hemminger <stephen@networkplumber.org>
CC: Jerry Chu <hkchu@google.com>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Veaceslav Falico authored and David S. Miller committed Apr 7, 2014
1 parent 6f25cd4 commit 6859e7d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -4589,8 +4589,7 @@ void *netdev_lower_get_next_private(struct net_device *dev,
if (&lower->list == &dev->adj_list.lower)
return NULL;

if (iter)
*iter = lower->list.next;
*iter = lower->list.next;

return lower->private;
}
Expand Down Expand Up @@ -4618,8 +4617,7 @@ void *netdev_lower_get_next_private_rcu(struct net_device *dev,
if (&lower->list == &dev->adj_list.lower)
return NULL;

if (iter)
*iter = &lower->list;
*iter = &lower->list;

return lower->private;
}
Expand Down

0 comments on commit 6859e7d

Please sign in to comment.