summaryrefslogtreecommitdiff
path: root/net/ipv6/route.c
diff options
context:
space:
mode:
authorMuhammad Usama Anjum <musamaanjum@gmail.com>2021-04-09 03:01:29 +0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-04-16 12:00:20 +0200
commitcfb476f1d9ec137052a2fb6b5609a622a4248289 (patch)
tree446a717e83cf8b1dca9e2f7493f483243dd65550 /net/ipv6/route.c
parent77de34b9f5029d68a47c00d9b462e425c546d679 (diff)
net: ipv6: check for validity before dereferencing cfg->fc_nlinfo.nlh
commit 864db232dc7036aa2de19749c3d5be0143b24f8f upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/ipv6/route.c')
-rw-r--r--net/ipv6/route.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 50eba77f5a0d..f06a76878746 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2980,9 +2980,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++;
}