Skip to content

Commit 86e31d7

Browse files
author
Guillaume Nault
committed
ppp: fix memory leak in pad_compress_skb
JIRA: https://issues.redhat.com/browse/RHEL-115633 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 e370d95 commit 86e31d7

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
}
@@ -1849,9 +1848,10 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
18491848
"down - pkt dropped.\n");
18501849
goto drop;
18511850
}
1852-
skb = pad_compress_skb(ppp, skb);
1853-
if (!skb)
1851+
new_skb = pad_compress_skb(ppp, skb);
1852+
if (!new_skb)
18541853
goto drop;
1854+
skb = new_skb;
18551855
}
18561856

18571857
/*

0 commit comments

Comments
 (0)