Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 426853f8 authored by Muhammad Usama Anjum's avatar Muhammad Usama Anjum Committed by Greg Kroah-Hartman
Browse files

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: default avatarMuhammad Usama Anjum <musamaanjum@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent df720c56
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -4514,9 +4514,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.
		 */
		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++;
	}