staging: rtl8192e use kmemdup and check its return value
authorXiaochen Wang <wangxiaochen0@gmail.com>
Sun, 6 Mar 2011 14:04:15 +0000 (22:04 +0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 7 Mar 2011 21:46:38 +0000 (13:46 -0800)
use kmemdup instead of kmalloc and memcpy,
and check its return value

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

index 88a9cd1958a88b085b420df1961977a6479b69b8..fc96676bb9ce75c65a79bc04e1404c7dfd5c1ab9 100644 (file)
@@ -1564,8 +1564,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;
                }
        }