Thread (1 message) 1 message, 1 author, 2019-03-03

Re: [PATCH] rsi: Fix NULL pointer dereference in kmalloc

From: Johannes Berg <johannes@sipsolutions.net>
Date: 2019-03-03 14:14:56
Also in: linux-wireless, lkml

On Sat, 2019-03-02 at 14:31 -0600, Aditya Pakki wrote:
quoted hunk
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 <redacted>
---
 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));
Should probably be kmemdup() anyway though.

johannes
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help