linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: kernel-janitors@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	Cliff Whickman <cpw@sgi.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Robin Holt <robinmholt@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 3/4] sgi-xpnet: Use common code in xpnet_dev_hard_start_xmit()
Date: Wed, 10 Jan 2018 11:24:51 +0100	[thread overview]
Message-ID: <1a05cc59-2d61-0152-798e-4d2f75094129@users.sourceforge.net> (raw)
In-Reply-To: <f1f2d65f-940f-f835-db4e-878e911f6011@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 10 Jan 2018 10:50:10 +0100

Add a jump target so that a bit of code can be better reused
at the end of this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/misc/sgi-xp/xpnet.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/misc/sgi-xp/xpnet.c b/drivers/misc/sgi-xp/xpnet.c
index a4415616c03c..088c96a883f9 100644
--- a/drivers/misc/sgi-xp/xpnet.c
+++ b/drivers/misc/sgi-xp/xpnet.c
@@ -416,11 +416,8 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 		"skb->end=0x%p skb->len=%d\n", (void *)skb->head,
 		(void *)skb->data, skb_tail_pointer(skb), skb_end_pointer(skb),
 		skb->len);
-
-	if (skb->data[0] == 0x33) {
-		dev_kfree_skb(skb);
-		return NETDEV_TX_OK;	/* nothing needed to be done */
-	}
+	if (skb->data[0] == 0x33)
+		goto free_skb;
 
 	/*
 	 * The xpnet_pending_msg tracks how many outstanding
@@ -430,8 +427,7 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	queued_msg = kmalloc(sizeof(*queued_msg), GFP_ATOMIC);
 	if (queued_msg == NULL) {
 		dev->stats.tx_errors++;
-		dev_kfree_skb(skb);
-		return NETDEV_TX_OK;
+		goto free_skb;
 	}
 
 	/* get the beginning of the first cacheline and end of last */
@@ -479,11 +475,15 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	dev->stats.tx_bytes += skb->len;
 
 	if (atomic_dec_return(&queued_msg->use_count) == 0) {
-		dev_kfree_skb(skb);
 		kfree(queued_msg);
+		goto free_skb;
 	}
 
 	return NETDEV_TX_OK;
+
+free_skb:
+	dev_kfree_skb(skb);
+	return NETDEV_TX_OK;
 }
 
 /*
-- 
2.15.1

  parent reply	other threads:[~2018-01-10 10:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-10 10:20 [PATCH 0/4] SGI-XPNET: Adjustments for five function implementations SF Markus Elfring
2018-01-10 10:22 ` [PATCH 1/4] sgi-xpnet: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
2018-01-10 10:23 ` [PATCH 2/4] sgi-xpnet: Improve a size determination in xpnet_dev_hard_start_xmit() SF Markus Elfring
2018-01-10 10:24 ` SF Markus Elfring [this message]
2018-01-10 10:25 ` [PATCH 4/4] sgi-xpnet: Adjust five checks for null pointers SF 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=1a05cc59-2d61-0152-798e-4d2f75094129@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=arnd@arndb.de \
    --cc=cpw@sgi.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robinmholt@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).