Skip to contentSkip to conversation

ppp: ppp_synctty: Use common error handling code in ppp_sync_txmunge()

PATCH Superseded Markus Elfring 2 participants 3 messages Sep 7 – Sep 15

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ppp: ppp_synctty: Use common error handling code in ppp_sync_txmunge()

From: Markus Elfring <[email protected]>
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.

---
 drivers/net/ppp/ppp_synctty.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/net/ppp/ppp_synctty.c +11 -8
index f87d43faeeab..270e0aae90a2 100644
@@ -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;
 }
 
 /*
Signature · 1 line
2.55.0
#1 lore raw
Quoted 2 lines

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/[email protected]/

Regards,
Markus

#2 lore raw

Hi,

Quoted 9 lines · Markus Elfring
Quoted 2 lines

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/[email protected]/

Regards,
Markus

This change is merged. You can now rebase and repost your patch.

Best regards,
Qingfang