drivers/net/ppp/ppp_synctty.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 7 Sep 2026 18:24:38 +0200
Use an additional label so that a bit of exception handling can be better
reused at the end of this function implementation.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/net/ppp/ppp_synctty.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c
index f87d43faeeab..270e0aae90a2 100644
--- a/drivers/net/ppp/ppp_synctty.c
+++ b/drivers/net/ppp/ppp_synctty.c
@@ -436,10 +436,9 @@ ppp_sync_txmunge(struct syncppp *ap, struct sk_buff *skb)
int islcp;
/* Ensure we can safely access protocol field and LCP code */
- if (!pskb_may_pull(skb, 3)) {
- kfree_skb(skb);
- return NULL;
- }
+ if (!pskb_may_pull(skb, 3))
+ goto free_skb;
+
data = skb->data;
proto = get_unaligned_be16(data);
@@ -457,10 +456,10 @@ ppp_sync_txmunge(struct syncppp *ap, struct sk_buff *skb)
if ((ap->flags & SC_COMP_AC) == 0 || islcp) {
if (skb_headroom(skb) < 2) {
struct sk_buff *npkt = dev_alloc_skb(skb->len + 2);
- if (npkt == NULL) {
- kfree_skb(skb);
- return NULL;
- }
+
+ if (!npkt)
+ goto free_skb;
+
skb_reserve(npkt,2);
skb_copy_from_linear_data(skb,
skb_put(npkt, skb->len), skb->len);
@@ -478,6 +477,10 @@ ppp_sync_txmunge(struct syncppp *ap, struct sk_buff *skb)
ppp_print_buffer ("send buffer", skb->data, skb->len);
return skb;
+
+free_skb:
+ kfree_skb(skb);
+ return NULL;
}
/*
--
2.55.0
> Use an additional label so that a bit of exception handling can be better > reused at the end of this function implementation. How do you think about to repeat the proposed source code transformation pattern after an other contribution would be integrated? [PATCH net] ppp_synctty: ensure a writeable skb header https://lore.kernel.org/linux-ppp/20260908072135.877364-1-qingfang.deng@linux.dev/ Regards, Markus
Hi, On 2026/9/8 15:48, Markus Elfring wrote: >> Use an additional label so that a bit of exception handling can be better >> reused at the end of this function implementation. > How do you think about to repeat the proposed source code transformation pattern > after an other contribution would be integrated? > [PATCH net] ppp_synctty: ensure a writeable skb header > https://lore.kernel.org/linux-ppp/20260908072135.877364-1-qingfang.deng@linux.dev/ > > Regards, > Markus This change is merged. You can now rebase and repost your patch. Best regards, Qingfang
© 2016 - 2026 Red Hat, Inc.