Commit 97bf6f81 authored by Xin Long's avatar Xin Long Committed by Jakub Kicinski

tipc: fix a possible memleak in tipc_buf_append

__skb_linearize() doesn't free the skb when it fails, so move
'*buf = NULL' after __skb_linearize(), so that the skb can be
freed on the err path.

Fixes: b7df21cf ("tipc: skb_linearize the head skb when reassembling msgs")
Reported-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Reviewed-by: default avatarTung Nguyen <tung.q.nguyen@dektech.com.au>
Link: https://lore.kernel.org/r/90710748c29a1521efac4f75ea01b3b7e61414cf.1714485818.git.lucien.xin@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 080cbb89
...@@ -142,9 +142,9 @@ int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf) ...@@ -142,9 +142,9 @@ int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf)
if (fragid == FIRST_FRAGMENT) { if (fragid == FIRST_FRAGMENT) {
if (unlikely(head)) if (unlikely(head))
goto err; goto err;
*buf = NULL;
if (skb_has_frag_list(frag) && __skb_linearize(frag)) if (skb_has_frag_list(frag) && __skb_linearize(frag))
goto err; goto err;
*buf = NULL;
frag = skb_unshare(frag, GFP_ATOMIC); frag = skb_unshare(frag, GFP_ATOMIC);
if (unlikely(!frag)) if (unlikely(!frag))
goto err; goto err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment