netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Pan Bian <bianpan2016@163.com>, Kalle Valo <kvalo@codeaurora.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.9 12/91] mwifiex: fix potential NULL dereference and use after free
Date: Fri, 22 Nov 2019 01:00:10 -0500	[thread overview]
Message-ID: <20191122060129.4239-11-sashal@kernel.org> (raw)
In-Reply-To: <20191122060129.4239-1-sashal@kernel.org>

From: Pan Bian <bianpan2016@163.com>

[ Upstream commit 1dcd9429212b98bea87fc6ec92fb50bf5953eb47 ]

There are two defects: (1) passing a NULL bss to
mwifiex_save_hidden_ssid_channels will result in NULL dereference,
(2) using bss after dropping the reference to it via cfg80211_put_bss.
To fix them, the patch moves the buggy code to the branch that bss is
not NULL and puts it before cfg80211_put_bss.

Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/wireless/marvell/mwifiex/scan.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c
index 7e96b6a37946a..828c6f5eb83c8 100644
--- a/drivers/net/wireless/marvell/mwifiex/scan.c
+++ b/drivers/net/wireless/marvell/mwifiex/scan.c
@@ -1890,15 +1890,17 @@ mwifiex_parse_single_response_buf(struct mwifiex_private *priv, u8 **bss_info,
 					    ETH_ALEN))
 					mwifiex_update_curr_bss_params(priv,
 								       bss);
-				cfg80211_put_bss(priv->wdev.wiphy, bss);
-			}
 
-			if ((chan->flags & IEEE80211_CHAN_RADAR) ||
-			    (chan->flags & IEEE80211_CHAN_NO_IR)) {
-				mwifiex_dbg(adapter, INFO,
-					    "radar or passive channel %d\n",
-					    channel);
-				mwifiex_save_hidden_ssid_channels(priv, bss);
+				if ((chan->flags & IEEE80211_CHAN_RADAR) ||
+				    (chan->flags & IEEE80211_CHAN_NO_IR)) {
+					mwifiex_dbg(adapter, INFO,
+						    "radar or passive channel %d\n",
+						    channel);
+					mwifiex_save_hidden_ssid_channels(priv,
+									  bss);
+				}
+
+				cfg80211_put_bss(priv->wdev.wiphy, bss);
 			}
 		}
 	} else {
-- 
2.20.1


       reply	other threads:[~2019-11-22  6:08 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20191122060129.4239-1-sashal@kernel.org>
2019-11-22  6:00 ` Sasha Levin [this message]
2019-11-22  6:00 ` [PATCH AUTOSEL 4.9 13/91] mwifiex: debugfs: correct histogram spacing, formatting Sasha Levin
2019-11-22  6:00 ` [PATCH AUTOSEL 4.9 14/91] rtl818x: fix potential use after free Sasha Levin
2019-11-22  6:00 ` [PATCH AUTOSEL 4.9 21/91] VSOCK: bind to random port for VMADDR_PORT_ANY Sasha Levin
2019-11-22  6:00 ` [PATCH AUTOSEL 4.9 27/91] net/mlx5: Continue driver initialization despite debugfs failure Sasha Levin
2019-11-22  6:00 ` [PATCH AUTOSEL 4.9 45/91] ath6kl: Only use match sets when firmware supports it Sasha Levin
2019-11-22  6:00 ` [PATCH AUTOSEL 4.9 46/91] ath6kl: Fix off by one error in scan completion Sasha Levin
2019-11-22  6:00 ` [PATCH AUTOSEL 4.9 61/91] net/net_namespace: Check the return value of register_pernet_subsys() Sasha Levin
2019-11-22  6:01 ` [PATCH AUTOSEL 4.9 63/91] net: stmicro: fix a missing check of clk_prepare Sasha Levin
2019-11-22  6:01 ` [PATCH AUTOSEL 4.9 64/91] net: dsa: bcm_sf2: Propagate error value from mdio_write Sasha Levin
2019-11-22  6:01 ` [PATCH AUTOSEL 4.9 65/91] atl1e: checking the status of atl1e_write_phy_reg Sasha Levin
2019-11-22  6:01 ` [PATCH AUTOSEL 4.9 66/91] tipc: fix a missing check of genlmsg_put Sasha Levin
2019-11-22  6:01 ` [PATCH AUTOSEL 4.9 67/91] net/wan/fsl_ucc_hdlc: Avoid double free in ucc_hdlc_probe() Sasha Levin
2019-11-22  6:01 ` [PATCH AUTOSEL 4.9 75/91] tipc: fix memory leak in tipc_nl_compat_publ_dump Sasha Levin
2019-11-22  6:01 ` [PATCH AUTOSEL 4.9 76/91] net/core/neighbour: tell kmemleak about hash tables Sasha Levin
2019-11-22  6:01 ` [PATCH AUTOSEL 4.9 77/91] net/core/neighbour: fix kmemleak minimal reference count for " Sasha Levin
2019-11-22  6:01 ` [PATCH AUTOSEL 4.9 78/91] sfc: suppress duplicate nvmem partition types in efx_ef10_mtd_probe Sasha Levin
2019-11-22  6:01 ` [PATCH AUTOSEL 4.9 79/91] ip_tunnel: Make none-tunnel-dst tunnel port work with lwtunnel Sasha Levin
2019-11-22  6:01 ` [PATCH AUTOSEL 4.9 80/91] decnet: fix DN_IFREQ_SIZE Sasha Levin
2019-11-22  6:01 ` [PATCH AUTOSEL 4.9 81/91] tipc: fix skb may be leaky in tipc_link_input Sasha Levin
2019-11-22  6:01 ` [PATCH AUTOSEL 4.9 82/91] sfc: initialise found bitmap in efx_ef10_mtd_probe Sasha Levin
2019-11-22  6:01 ` [PATCH AUTOSEL 4.9 83/91] net: fix possible overflow in __sk_mem_raise_allocated() Sasha Levin
2019-11-22  6:01 ` [PATCH AUTOSEL 4.9 84/91] sctp: don't compare hb_timer expire date before starting it Sasha Levin
2019-11-22  6:01 ` [PATCH AUTOSEL 4.9 85/91] net: dev: Use unsigned integer as an argument to left-shift Sasha Levin

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=20191122060129.4239-11-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=bianpan2016@163.com \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /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).