net: mwifiex: fix a NULL pointer dereference
authorKangjie Lu <kjlu@umn.edu>
Tue, 12 Mar 2019 05:31:07 +0000 (00:31 -0500)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 4 Apr 2019 10:17:55 +0000 (13:17 +0300)
In case dev_alloc_skb fails, the fix returns -ENOMEM to avoid
NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/marvell/mwifiex/cmdevt.c

index 60db2b969e20d7d8f5b7119ed6636ccda132cdfd..8c35441fd9b7dbc2f3d4a1f46753323c8a29bce4 100644 (file)
@@ -341,6 +341,12 @@ 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) {
+                       mwifiex_dbg(adapter, ERROR,
+                                   "SLEEP_CFM: dev_alloc_skb failed\n");
+                       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);