staging: rtl8192e: Fix potential null dereference
authorHema Prathaban <hemaklnce@gmail.com>
Tue, 14 May 2013 15:29:19 +0000 (20:59 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 May 2013 18:23:40 +0000 (14:23 -0400)
check memory is allocated in '*challenge' before using it.

Signed-off-by: Hema Prathaban <hemaklnce@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8192e/rtllib_softmac.c

index 4feecec8609c696e29e745a0b2b7833def2f917b..8af0b9902615fc5032d27d5ddeb70481792ee372 100644 (file)
@@ -1802,7 +1802,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);  /*TODO - check here*/
+                       if (!*challenge)
+                               return -ENOMEM;
+                       memcpy(*challenge, t, *chlen);
                }
        }
        return cpu_to_le16(a->status);