netlink: Fix potential skb memleak in netlink_ack
authorTao Chen <chentao.kernel@linux.alibaba.com>
Sat, 5 Nov 2022 09:05:04 +0000 (17:05 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Oct 2023 20:00:44 +0000 (22:00 +0200)
commit0915de8c6083e02905095cdb5850255289ebe291
tree3b81d72e4978cac94a9c6d6237402dad43d1d7eb
parent1a6e2da05f379dd465a6be40ee44567824d2b292
netlink: Fix potential skb memleak in netlink_ack

[ Upstream commit e69761483361f3df455bc493c99af0ef1744a14f ]

Fix coverity issue 'Resource leak'.

We should clean the skb resource if nlmsg_put/append failed.

Fixes: 738136a0e375 ("netlink: split up copies in the ack construction")
Signed-off-by: Tao Chen <chentao.kernel@linux.alibaba.com>
Link: https://lore.kernel.org/r/bff442d62c87de6299817fe1897cc5a5694ba9cc.1667638204.git.chentao.kernel@linux.alibaba.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: d0f95894fda7 ("netlink: annotate data-races around sk->sk_err")
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/netlink/af_netlink.c