mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 net-next] ppp_synctty: Use common error handling code in ppp_sync_txmunge()
@ 2026-09-15  9:23 Markus Elfring
  2026-09-16 12:49 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2026-09-15  9:23 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

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 15 Sep 2026 10:48:11 +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>
---

v2:
The application of a known source code transformation pattern could be repeated
after the commit 8aaeb56aff2a557a88f83ae866da2c91ad247e59 ("ppp_synctty:
ensure a writeable skb header") was integrated.

 drivers/net/ppp/ppp_synctty.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c
index ebd62a7ab54b..9e440e110e9f 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);
 
@@ -455,10 +454,9 @@ ppp_sync_txmunge(struct syncppp *ap, struct sk_buff *skb)
 
 	/* prepend address/control fields if necessary */
 	if ((ap->flags & SC_COMP_AC) == 0 || islcp) {
-		if (skb_cow_head(skb, 2)) {
-			kfree_skb(skb);
-			return NULL;
-		}
+		if (skb_cow_head(skb, 2))
+			goto free_skb;
+
 		skb_push(skb,2);
 		skb->data[0] = PPP_ALLSTATIONS;
 		skb->data[1] = PPP_UI;
@@ -470,6 +468,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;
 }
 
 /*

base-commit: 8aaeb56aff2a557a88f83ae866da2c91ad247e59
-- 
2.55.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 net-next] ppp_synctty: Use common error handling code in ppp_sync_txmunge()
  2026-09-15  9:23 [PATCH v2 net-next] ppp_synctty: Use common error handling code in ppp_sync_txmunge() Markus Elfring
@ 2026-09-16 12:49 ` Simon Horman
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2026-09-16 12:49 UTC (permalink / raw)
  To: Markus Elfring
  Cc: linux-ppp, netdev, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Jiri Slaby, Paolo Abeni, Qingfang Deng,
	Tom Parkin, LKML, Kees Cook

On Tue, Sep 15, 2026 at 11:23:01AM +0200, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 15 Sep 2026 10:48:11 +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>
> ---
> 
> v2:
> The application of a known source code transformation pattern could be repeated
> after the commit 8aaeb56aff2a557a88f83ae866da2c91ad247e59 ("ppp_synctty:
> ensure a writeable skb header") was integrated.

I have mixed feelings about this as it seems to be a cleanup
outside of the context of other work [1].

But I believe it is correct and does use the preferred goto label based
cleanup mechanism.

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-16 12:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-15  9:23 [PATCH v2 net-next] ppp_synctty: Use common error handling code in ppp_sync_txmunge() Markus Elfring
2026-09-16 12:49 ` Simon Horman

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®