Skip to content

Commit

Permalink
net: iface: Fix bad comparisons in net_if
Browse files Browse the repository at this point in the history
Fix comparisons in net_if_get_by_index and net_if_get_by_iface:
__net_if_end is not a pointer to a net_if structure.

Change-Id: Ie8e3a457c3f0fa97c080b38b5b7d2b420c50252b
Signed-off-by: Julien Chevrier <[email protected]>
  • Loading branch information
jchevrier authored and jukkar committed Feb 3, 2017
1 parent 3c95a56 commit 6aae825
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions subsys/net/ip/net_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ void net_if_call_link_cb(struct net_if *iface, struct net_linkaddr *lladdr,

struct net_if *net_if_get_by_index(uint8_t index)
{
if (&__net_if_start[index] > __net_if_end) {
if (&__net_if_start[index] >= __net_if_end) {
NET_DBG("Index %d is too large", index);
return NULL;
}
Expand All @@ -1317,7 +1317,7 @@ struct net_if *net_if_get_by_index(uint8_t index)

uint8_t net_if_get_by_iface(struct net_if *iface)
{
NET_ASSERT(iface >= __net_if_start && iface <= __net_if_end);
NET_ASSERT(iface >= __net_if_start && iface < __net_if_end);

return iface - __net_if_start;
}
Expand Down

0 comments on commit 6aae825

Please sign in to comment.