Skip to content

Commit

Permalink
net: ipv6: check for validity before dereferencing cfg->fc_nlinfo.nlh
Browse files Browse the repository at this point in the history
nlh is being checked for validtity two times when it is dereferenced in
this function. Check for validity again when updating the flags through
nlh pointer to make the dereferencing safe.

CC: <stable@vger.kernel.org>
Addresses-Coverity: ("NULL pointer dereference")
Signed-off-by: Muhammad Usama Anjum <musamaanjum@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
musamaanjum authored and davem330 committed Apr 8, 2021
1 parent 2d1b50a commit 864db23
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions net/ipv6/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -5209,9 +5209,11 @@ static int ip6_route_multipath_add(struct fib6_config *cfg,
* nexthops have been replaced by first new, the rest should
* be added to it.
*/
cfg->fc_nlinfo.nlh->nlmsg_flags &= ~(NLM_F_EXCL |
NLM_F_REPLACE);
cfg->fc_nlinfo.nlh->nlmsg_flags |= NLM_F_CREATE;
if (cfg->fc_nlinfo.nlh) {
cfg->fc_nlinfo.nlh->nlmsg_flags &= ~(NLM_F_EXCL |
NLM_F_REPLACE);
cfg->fc_nlinfo.nlh->nlmsg_flags |= NLM_F_CREATE;
}
nhn++;
}

Expand Down

0 comments on commit 864db23

Please sign in to comment.