OSDN Git Service

staging: wlan-ng: check return value of kmalloc
authorGujulan Elango, Hari Prasath (H.) <hgujulan@visteon.com>
Wed, 13 May 2015 14:35:25 +0000 (14:35 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 31 May 2015 01:01:51 +0000 (10:01 +0900)
check return value of kmalloc before accessing the memory pointer and
return -ENOMEM if allocation fails.

Signed-off-by: Hari Prasath Gujulan Elango <hgujulan@visteon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wlan-ng/p80211conv.c

index bd69e8c..c0e6ac8 100644 (file)
@@ -207,6 +207,8 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
                /* XXXX need to pick keynum other than default? */
 
                p80211_wep->data = kmalloc(skb->len, GFP_ATOMIC);
+               if (!p80211_wep->data)
+                       return -ENOMEM;
                foo = wep_encrypt(wlandev, skb->data, p80211_wep->data,
                                  skb->len,
                                  (wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK),