diff mbox series

mwifiex: Fix potential NULL pointer dereference

Message ID 20190313184229.24780-1-pakki001@umn.edu (mailing list archive)
State Superseded
Delegated to: Kalle Valo
Headers show
Series mwifiex: Fix potential NULL pointer dereference | expand

Commit Message

Aditya Pakki March 13, 2019, 6:42 p.m. UTC
dev_alloc_skb can fail and return a NULL pointer. The patch avoids
a potential NULL pointer dereference and returns -ENOMEM.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 drivers/net/wireless/marvell/mwifiex/cmdevt.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Kalle Valo April 4, 2019, 10:20 a.m. UTC | #1
Aditya Pakki <pakki001@umn.edu> wrote:

> dev_alloc_skb can fail and return a NULL pointer. The patch avoids
> a potential NULL pointer dereference and returns -ENOMEM.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>

A similar patch was already submitted:

https://patchwork.kernel.org/patch/10848599/

Patch set to Superseded.
diff mbox series

Patch

diff --git a/drivers/net/wireless/marvell/mwifiex/cmdevt.c b/drivers/net/wireless/marvell/mwifiex/cmdevt.c
index 60db2b969e20..4e2fa972a78a 100644
--- a/drivers/net/wireless/marvell/mwifiex/cmdevt.c
+++ b/drivers/net/wireless/marvell/mwifiex/cmdevt.c
@@ -341,6 +341,9 @@  static int mwifiex_dnld_sleep_confirm_cmd(struct mwifiex_adapter *adapter)
 		sleep_cfm_tmp =
 			dev_alloc_skb(sizeof(struct mwifiex_opt_sleep_confirm)
 				      + MWIFIEX_TYPE_LEN);
+		if (!sleep_cfm_tmp)
+			return -ENOMEM;
+
 		skb_put(sleep_cfm_tmp, sizeof(struct mwifiex_opt_sleep_confirm)
 			+ MWIFIEX_TYPE_LEN);
 		put_unaligned_le32(MWIFIEX_USB_TYPE_CMD, sleep_cfm_tmp->data);