Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

netlink: Fix potential skb memleak in netlink_ack

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>

authored by

Tao Chen and committed by
Jakub Kicinski
e6976148 14ef5c39

+3 -1
+3 -1
net/netlink/af_netlink.c
··· 2500 2500 2501 2501 skb = nlmsg_new(payload + tlvlen, GFP_KERNEL); 2502 2502 if (!skb) 2503 - goto err_bad_put; 2503 + goto err_skb; 2504 2504 2505 2505 rep = nlmsg_put(skb, NETLINK_CB(in_skb).portid, nlh->nlmsg_seq, 2506 2506 NLMSG_ERROR, sizeof(*errmsg), flags); ··· 2528 2528 return; 2529 2529 2530 2530 err_bad_put: 2531 + nlmsg_free(skb); 2532 + err_skb: 2531 2533 NETLINK_CB(in_skb).sk->sk_err = ENOBUFS; 2532 2534 sk_error_report(NETLINK_CB(in_skb).sk); 2533 2535 }