linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xinming Hu <huxinming820@gmail.com>
To: Linux Wireless <linux-wireless@vger.kernel.org>
Cc: Kalle Valo <kvalo@qca.qualcomm.com>,
	Brian Norris <briannorris@google.com>,
	Dmitry Torokhov <dtor@google.com>,
	rajatja@google.com, Zhiyuan Yang <yangzy@marvell.com>,
	Cathy Luo <cluo@marvell.com>, Xinming Hu <huxm@marvell.com>
Subject: [PATCH 2/6] mwifiex: usb: urb->context sanity check in complete handler
Date: Wed,  3 May 2017 11:48:39 +0000	[thread overview]
Message-ID: <1493812123-12053-2-git-send-email-huxinming820@gmail.com> (raw)
In-Reply-To: <1493812123-12053-1-git-send-email-huxinming820@gmail.com>

From: Xinming Hu <huxm@marvell.com>

urb/context might be freed in cornel case, add sanity check to avoid
use-after-free.

Signed-off-by: Xinming Hu <huxm@marvell.com>
---
 drivers/net/wireless/marvell/mwifiex/usb.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c b/drivers/net/wireless/marvell/mwifiex/usb.c
index 2f7705c..ee5f488 100644
--- a/drivers/net/wireless/marvell/mwifiex/usb.c
+++ b/drivers/net/wireless/marvell/mwifiex/usb.c
@@ -169,6 +169,11 @@ static void mwifiex_usb_rx_complete(struct urb *urb)
 	int recv_length = urb->actual_length;
 	int size, status;
 
+	if (!urb || !urb->context) {
+		pr_err("URB or URB context is not valid in USB Rx complete\n");
+		return;
+	}
+
 	if (!adapter || !adapter->card) {
 		pr_err("mwifiex adapter or card structure is not valid\n");
 		return;
@@ -260,6 +265,11 @@ static void mwifiex_usb_tx_complete(struct urb *urb)
 	struct usb_tx_data_port *port;
 	int i;
 
+	if (!urb || !urb->context) {
+		pr_err("URB or URB context is not valid in USB Tx complete\n");
+		return;
+	}
+
 	mwifiex_dbg(adapter, INFO,
 		    "%s: status: %d\n", __func__, urb->status);
 
-- 
1.9.1

  reply	other threads:[~2017-05-03 11:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-03 11:48 [PATCH 1/6] mwifiex: use variable interface header length Xinming Hu
2017-05-03 11:48 ` Xinming Hu [this message]
2017-05-03 18:51   ` [PATCH 2/6] mwifiex: usb: urb->context sanity check in complete handler Arend Van Spriel
2017-05-04  9:12     ` Xinming Hu
2017-05-03 11:48 ` [PATCH 3/6] mwifiex: usb: transmit aggregation packets Xinming Hu
2017-05-03 11:48 ` [PATCH 4/6] mwifiex: usb: add timer to flush " Xinming Hu
2017-05-03 11:48 ` [PATCH 5/6] mwifiex: do not aggregate tcp ack in usb tx aggregation queue Xinming Hu
2017-05-03 11:48 ` [PATCH 6/6] mwifiex: check next packet length for usb tx aggregation Xinming Hu

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=1493812123-12053-2-git-send-email-huxinming820@gmail.com \
    --to=huxinming820@gmail.com \
    --cc=briannorris@google.com \
    --cc=cluo@marvell.com \
    --cc=dtor@google.com \
    --cc=huxm@marvell.com \
    --cc=kvalo@qca.qualcomm.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=rajatja@google.com \
    --cc=yangzy@marvell.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).