Re: [PATCH] ipv6: Fix nexthop refcnt leak when creating ipv6 route info

From: David Miller
Date: Tue Jul 28 2020 - 20:24:50 EST


From: Xiyu Yang <xiyuyang19@xxxxxxxxxxxx>
Date: Sat, 25 Jul 2020 16:02:18 +0800

> 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.
>
> Signed-off-by: Xiyu Yang <xiyuyang19@xxxxxxxxxxxx>
> Signed-off-by: Xin Tan <tanxin.ctf@xxxxxxxxx>

Applied and queued up for -stable, thanks.