All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: linux-wireless@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Kalle Valo <kvalo@codeaurora.org>, Dan Williams <dcbw@redhat.com>,
	Jes Sorensen <jes.sorensen@gmail.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: [PATCH 01/10] orinoco: Move context allocation after processing the skb
Date: Fri, 13 Nov 2020 22:22:43 +0100	[thread overview]
Message-ID: <20201113212252.2243570-2-bigeasy@linutronix.de> (raw)
In-Reply-To: <20201113212252.2243570-1-bigeasy@linutronix.de>

ezusb_xmit() allocates a context which is leaked if
orinoco_process_xmit_skb() returns an error.

Move ezusb_alloc_ctx() after the invocation of
orinoco_process_xmit_skb() because the context is not needed so early.
ezusb_access_ltv() will cleanup the context in case of an error.

Fixes: bac6fafd4d6a0 ("orinoco: refactor xmit path")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 .../net/wireless/intersil/orinoco/orinoco_usb.c    | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c
index 046f2453ad5d9..8419e13a79e2a 100644
--- a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c
+++ b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c
@@ -1221,13 +1221,6 @@ static netdev_tx_t ezusb_xmit(struct sk_buff *skb, struct net_device *dev)
 	if (skb->len < ETH_HLEN)
 		goto drop;
 
-	ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_TX, 0);
-	if (!ctx)
-		goto busy;
-
-	memset(ctx->buf, 0, BULK_BUF_SIZE);
-	buf = ctx->buf->data;
-
 	tx_control = 0;
 
 	err = orinoco_process_xmit_skb(skb, dev, priv, &tx_control,
@@ -1235,6 +1228,13 @@ static netdev_tx_t ezusb_xmit(struct sk_buff *skb, struct net_device *dev)
 	if (err)
 		goto drop;
 
+	ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_TX, 0);
+	if (!ctx)
+		goto drop;
+
+	memset(ctx->buf, 0, BULK_BUF_SIZE);
+	buf = ctx->buf->data;
+
 	{
 		__le16 *tx_cntl = (__le16 *)buf;
 		*tx_cntl = cpu_to_le16(tx_control);
-- 
2.29.2


  reply	other threads:[~2020-11-13 21:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-13 21:22 [PATCH 00/10] orinoco: Remove in_interrupt() usage Sebastian Andrzej Siewior
2020-11-13 21:22 ` Sebastian Andrzej Siewior [this message]
2020-11-24 15:01   ` [PATCH 01/10] orinoco: Move context allocation after processing the skb Kalle Valo
2020-11-13 21:22 ` [PATCH 02/10] orinoco: Prepare stubs for in_interrupt() removal Sebastian Andrzej Siewior
2020-11-13 21:22 ` [PATCH 03/10] orinoco: Annotate ezusb_xmit() Sebastian Andrzej Siewior
2020-11-13 21:22 ` [PATCH 04/10] orinoco: Annotate ezusb_init() Sebastian Andrzej Siewior
2020-11-13 21:22 ` [PATCH 05/10] orinoco: Annotate firmware loading Sebastian Andrzej Siewior
2020-11-13 21:22 ` [PATCH 06/10] orinoco: Annotate ezusb_read_pda() Sebastian Andrzej Siewior
2020-11-13 21:22 ` [PATCH 07/10] orinoco: Annotate ezusb_write_ltv() Sebastian Andrzej Siewior
2020-11-13 21:22 ` [PATCH 08/10] orinoco: Remove ezusb_doicmd_wait() Sebastian Andrzej Siewior
2020-11-13 21:22 ` [PATCH 09/10] orinoco: Annotate ezusb_docmd_wait() Sebastian Andrzej Siewior
2020-11-13 21:22 ` [PATCH 10/10] orinoco: Annotate ezusb_read_ltv() Sebastian Andrzej Siewior

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=20201113212252.2243570-2-bigeasy@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=dcbw@redhat.com \
    --cc=jes.sorensen@gmail.com \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.