Skip to content

Commit 5e4176c

Browse files
author
Guillaume Nault
committed
ppp: fix memory leak in pad_compress_skb
JIRA: https://issues.redhat.com/browse/RHEL-115585 Upstream Status: linux.git commit 4844123 Author: Qingfang Deng <dqfext@gmail.com> Date: Wed Sep 3 18:07:26 2025 +0800 ppp: fix memory leak in pad_compress_skb If alloc_skb() fails in pad_compress_skb(), it returns NULL without releasing the old skb. The caller does: skb = pad_compress_skb(ppp, skb); if (!skb) goto drop; drop: kfree_skb(skb); When pad_compress_skb() returns NULL, the reference to the old skb is lost and kfree_skb(skb) ends up doing nothing, leading to a memory leak. Align pad_compress_skb() semantics with realloc(): only free the old skb if allocation and compression succeed. At the call site, use the new_skb variable so the original skb is not lost when pad_compress_skb() fails. Fixes: b3f9b92 ("[PPP]: add PPP MPPE encryption module") Signed-off-by: Qingfang Deng <dqfext@gmail.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Yue Haibing <yuehaibing@huawei.com> Link: https://patch.msgid.link/20250903100726.269839-1-dqfext@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Guillaume Nault <gnault@redhat.com>
1 parent 45c7277 commit 5e4176c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/net/ppp/ppp_generic.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,7 +1749,6 @@ pad_compress_skb(struct ppp *ppp, struct sk_buff *skb)
17491749
*/
17501750
if (net_ratelimit())
17511751
netdev_err(ppp->dev, "ppp: compressor dropped pkt\n");
1752-
kfree_skb(skb);
17531752
consume_skb(new_skb);
17541753
new_skb = NULL;
17551754
}
@@ -1851,9 +1850,10 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
18511850
"down - pkt dropped.\n");
18521851
goto drop;
18531852
}
1854-
skb = pad_compress_skb(ppp, skb);
1855-
if (!skb)
1853+
new_skb = pad_compress_skb(ppp, skb);
1854+
if (!new_skb)
18561855
goto drop;
1856+
skb = new_skb;
18571857
}
18581858

18591859
/*

0 commit comments

Comments
 (0)