Thread (2 messages) flat view 2 messages, 1 author, 2d ago
WARM2d

[PATCH net-next] ppp: ppp_synctty: Use common error handling code in ppp_sync_txmunge()

From: Markus Elfring <hidden>
Date: 2026-09-07 16:41:14
Also in: lkml
Subsystem: networking drivers, ppp protocol drivers and compressors, the rest · Maintainers: Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

From: Markus Elfring <redacted>
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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help