From: Nicolas Dichtel Date: Thu, 27 Nov 2014 09:16:15 +0000 (+0100) Subject: rtnetlink: release net refcnt on error in do_setlink() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e0ebde0e131b529fd721b24f62872def5ec3718c;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git rtnetlink: release net refcnt on error in do_setlink() rtnl_link_get_net() holds a reference on the 'struct net', we need to release it in case of error. CC: Eric W. Biederman Fixes: b51642f6d77b ("net: Enable a userns root rtnl calls that are safe for unprivilged users") Signed-off-by: Nicolas Dichtel Reviewed-by: "Eric W. Biederman" Signed-off-by: David S. Miller --- diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index b9b7dfaf202b..76321ea442c3 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -1498,6 +1498,7 @@ static int do_setlink(const struct sk_buff *skb, goto errout; } if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) { + put_net(net); err = -EPERM; goto errout; }