[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190302203123.9182-1-pakki001@umn.edu>
Date: Sat, 2 Mar 2019 14:31:22 -0600
From: Aditya Pakki <pakki001@....edu>
To: pakki001@....edu
Cc: kjlu@....edu, Amitkumar Karwar <amitkarwar@...il.com>,
Siva Rebbagondla <siva8118@...il.com>,
Kalle Valo <kvalo@...eaurora.org>,
"David S. Miller" <davem@...emloft.net>,
linux-wireless@...r.kernel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] rsi: Fix NULL pointer dereference in kmalloc
kmalloc can fail in rsi_register_rates_channels but memcpy still attempts
to write to channels. The patch checks and avoids such a situation.
Signed-off-by: Aditya Pakki <pakki001@....edu>
---
drivers/net/wireless/rsi/rsi_91x_mac80211.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/net/wireless/rsi/rsi_91x_mac80211.c b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
index e56fc83faf0e..59eb1f533d0e 100644
--- a/drivers/net/wireless/rsi/rsi_91x_mac80211.c
+++ b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
@@ -197,6 +197,11 @@ static void rsi_register_rates_channels(struct rsi_hw *adapter, int band)
if (band == NL80211_BAND_2GHZ) {
channels = kmalloc(sizeof(rsi_2ghz_channels), GFP_KERNEL);
+ if (!channels) {
+ rsi_dbg(ERR_ZONE, "Failed to allocate memory\n");
+ return;
+ }
+
memcpy(channels,
rsi_2ghz_channels,
sizeof(rsi_2ghz_channels));
@@ -206,6 +211,11 @@ static void rsi_register_rates_channels(struct rsi_hw *adapter, int band)
sbands->n_bitrates = ARRAY_SIZE(rsi_rates);
} else {
channels = kmalloc(sizeof(rsi_5ghz_channels), GFP_KERNEL);
+ if (!channels) {
+ rsi_dbg(ERR_ZONE, "Failed to allocate memory\n");
+ return;
+ }
+
memcpy(channels,
rsi_5ghz_channels,
sizeof(rsi_5ghz_channels));
--
2.17.1
Powered by blists - more mailing lists