]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: rtl8192e: Use kmemdup for duplicating memory
authorHema Prathaban <hemaklnce@gmail.com>
Tue, 14 May 2013 15:31:22 +0000 (21:01 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 May 2013 18:23:41 +0000 (14:23 -0400)
Instead of allocating memory (kmalloc) and copying (memcpy)
from source, memory can be duplicated using kmemdup

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

index 8af0b9902615fc5032d27d5ddeb70481792ee372..aefffac556a66c7c273b3cc32fc8b2d33a4a0a7e 100644 (file)
@@ -1801,10 +1801,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);
+                       *challenge = kmemdup(t, *chlen, GFP_ATOMIC);
                        if (!*challenge)
                                return -ENOMEM;
-                       memcpy(*challenge, t, *chlen);
                }
        }
        return cpu_to_le16(a->status);