diff options
author | Muhammad Usama Anjum <musamaanjum@gmail.com> | 2021-04-09 00:01:29 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-04-09 01:41:46 +0200 |
commit | 864db232dc7036aa2de19749c3d5be0143b24f8f (patch) | |
tree | dc7d062aa31dd41d2dde3653442a412fec116fef /net/ipv6/route.c | |
parent | Merge branch 'lantiq-GSWIP-fixes' (diff) | |
download | linux-864db232dc7036aa2de19749c3d5be0143b24f8f.tar.xz linux-864db232dc7036aa2de19749c3d5be0143b24f8f.zip |
net: ipv6: check for validity before dereferencing cfg->fc_nlinfo.nlh
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>
Diffstat (limited to 'net/ipv6/route.c')
-rw-r--r-- | net/ipv6/route.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 1056b0229ffd..373d48073106 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -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++; } |