staging: rtl8187se: check kmalloc return value
authorXiaochen Wang <wangxiaochen0@gmail.com>
Fri, 4 Mar 2011 05:09:00 +0000 (13:09 +0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 7 Mar 2011 21:46:38 +0000 (13:46 -0800)
check kmalloc return value

Signed-off-by: Xiaochen Wang <wangxiaochen0@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c

index 652d879509e6b0e0b18cb56611dfc1c87f9e39d6..74a3b4c211ad41c94789b386f11d97b3661a97a0 100644 (file)
@@ -1435,8 +1435,9 @@ static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen)
 
                if(*(t++) == MFIE_TYPE_CHALLENGE){
                        *chlen = *(t++);
-                       *challenge = kmalloc(*chlen, GFP_ATOMIC);
-                       memcpy(*challenge, t, *chlen);
+                       *challenge = kmemdup(t, *chlen, GFP_ATOMIC);
+                       if (!*challenge)
+                               return -ENOMEM;
                }
        }