]> git.baikalelectronics.ru Git - kernel.git/commit
ipv6: Fix nexthop refcnt leak when creating ipv6 route info
authorXiyu Yang <xiyuyang19@fudan.edu.cn>
Sat, 25 Jul 2020 08:02:18 +0000 (16:02 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 29 Jul 2020 00:24:08 +0000 (17:24 -0700)
commitbbe296d0bc01b0065a17306469d5d44665ed47f9
treee3cfda7e04b287deb5b8bcb137840e3267f90022
parent43461c24212d82938aa8345d91857e14724ba343
ipv6: Fix nexthop refcnt leak when creating ipv6 route info

ip6_route_info_create() invokes nexthop_get(), which increases the
refcount of the "nh".

When ip6_route_info_create() returns, local variable "nh" becomes
invalid, so the refcount should be decreased to keep refcount balanced.

The reference counting issue happens in one exception handling path of
ip6_route_info_create(). When nexthops can not be used with source
routing, the function forgets to decrease the refcnt increased by
nexthop_get(), causing a refcnt leak.

Fix this issue by pulling up the error source routing handling when
nexthops can not be used with source routing.

Fixes: b6b1bd779ad2 ("ipv6: Plumb support for nexthop object in a fib6_info")
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/route.c