Skip to contentSkip to conversation

mwifiex: usb: return an error if kmalloc fails

PATCH Applied Dan Carpenter 3 participants 3 messages Aug 4, 2015 – Aug 13, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mwifiex: usb: return an error if kmalloc fails

The current code returns success if kmalloc fails.

drivers/net/wireless/mwifiex/usb.c +3 -1
index fbad99c..f866d5d 100644
@@ -870,8 +870,10 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter,
 
 	/* Allocate memory for transmit */
 	fwdata = kzalloc(FW_DNLD_TX_BUF_SIZE, GFP_KERNEL);
-	if (!fwdata)
+	if (!fwdata) {
+		ret = -ENOMEM;
 		goto fw_exit;
+	}
 
 	/* Allocate memory for receive */
 	recv_buff = kzalloc(FW_DNLD_RX_BUF_SIZE, GFP_KERNEL);
Acked-by on v1 1/1
#1 lore raw

Hi Dan,

Quoted 28 lines

From: Dan Carpenter [mailto:[email protected]]
Sent: Tuesday, August 04, 2015 1:19 PM
To: Amitkumar Karwar
Cc: Nishant Sarmukadam; Kalle Valo; [email protected]; [email protected]
Subject: [patch] mwifiex: usb: return an error if kmalloc fails

The current code returns success if kmalloc fails.

drivers/net/wireless/mwifiex/usb.c +3 -1
index fbad99c..f866d5d 100644
@@ -870,8 +870,10 @@ static int mwifiex_prog_fw_w_helper(struct
 mwifiex_adapter *adapter,
 
 	/* Allocate memory for transmit */
 	fwdata = kzalloc(FW_DNLD_TX_BUF_SIZE, GFP_KERNEL);
-	if (!fwdata)
+	if (!fwdata) {
+		ret = -ENOMEM;
 		goto fw_exit;
+	}
 
 	/* Allocate memory for receive */
Quoted 1 line

recv_buff = kzalloc(FW_DNLD_RX_BUF_SIZE, GFP_KERNEL);

Regards,
Amitkumar