Commit 5270041d authored by Dan Carpenter's avatar Dan Carpenter Committed by David S. Miller

nexthop: off by one in nexthop_mpath_select()

The nhg->nh_entries[] array is allocated in nexthop_grp_alloc() and it
has nhg->num_nh elements so this check should be >= instead of >.

Fixes: 430a0491 ("nexthop: Add support for nexthop groups")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 90b8b7e7
...@@ -160,7 +160,7 @@ struct nexthop *nexthop_mpath_select(const struct nexthop *nh, int nhsel) ...@@ -160,7 +160,7 @@ struct nexthop *nexthop_mpath_select(const struct nexthop *nh, int nhsel)
/* for_nexthops macros in fib_semantics.c grabs a pointer to /* for_nexthops macros in fib_semantics.c grabs a pointer to
* the nexthop before checking nhsel * the nexthop before checking nhsel
*/ */
if (nhsel > nhg->num_nh) if (nhsel >= nhg->num_nh)
return NULL; return NULL;
return nhg->nh_entries[nhsel].nh; return nhg->nh_entries[nhsel].nh;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment