mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: linux-ppp@vger.kernel.org, netdev@vger.kernel.org,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Jiri Slaby <jirislaby@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Qingfang Deng <qingfang.deng@linux.dev>
Cc: LKML <linux-kernel@vger.kernel.org>, Kees Cook <kees@kernel.org>
Subject: [PATCH net-next] ppp: ppp_synctty: Use common error handling code in ppp_sync_txmunge()
Date: Mon, 7 Sep 2026 18:40:47 +0200	[thread overview]
Message-ID: <1d943bf2-d027-41aa-82db-b2f0807a5e7c@web.de> (raw)

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


             reply	other threads:[~2026-09-07 16:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07 16:40 Markus Elfring [this message]
2026-09-08  7:48 ` Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1d943bf2-d027-41aa-82db-b2f0807a5e7c@web.de \
    --to=markus.elfring@web.de \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jirislaby@kernel.org \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-ppp@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=qingfang.deng@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®