* [PATCH net-next] ppp: ppp_synctty: Use common error handling code in ppp_sync_txmunge()
@ 2026-09-07 16:40 Markus Elfring
2026-09-08 7:48 ` Markus Elfring
0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2026-09-07 16:40 UTC (permalink / raw)
To: linux-ppp, netdev, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Jiri Slaby, Paolo Abeni, Qingfang Deng
Cc: LKML, Kees Cook
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] ppp: ppp_synctty: Use common error handling code in ppp_sync_txmunge()
2026-09-07 16:40 [PATCH net-next] ppp: ppp_synctty: Use common error handling code in ppp_sync_txmunge() Markus Elfring
@ 2026-09-08 7:48 ` Markus Elfring
0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2026-09-08 7:48 UTC (permalink / raw)
To: linux-ppp, netdev, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Jiri Slaby, Paolo Abeni, Qingfang Deng,
Tom Parkin
Cc: LKML, Kees Cook
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-08 7:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-07 16:40 [PATCH net-next] ppp: ppp_synctty: Use common error handling code in ppp_sync_txmunge() Markus Elfring
2026-09-08 7:48 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®