Input: wistron_btns - switch to using kmemdup()
authorJulia Lawall <julia@diku.dk>
Wed, 19 May 2010 17:11:14 +0000 (10:11 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 19 May 2010 17:14:38 +0000 (10:14 -0700)
Use kmemdup when some other buffer is immediately copied into the
allocated region.

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
drivers/input/misc/wistron_btns.c

index 04d5a4a3181ff847cbdfc9bf4bec1a5e9c8f1540..4dac8b79fcd4fc50ad1908ce3ae368cdd56085ed 100644 (file)
@@ -983,11 +983,11 @@ static int __init copy_keymap(void)
        for (key = keymap; key->type != KE_END; key++)
                length++;
 
-       new_keymap = kmalloc(length * sizeof(struct key_entry), GFP_KERNEL);
+       new_keymap = kmemdup(keymap, length * sizeof(struct key_entry),
+                            GFP_KERNEL);
        if (!new_keymap)
                return -ENOMEM;
 
-       memcpy(new_keymap, keymap, length * sizeof(struct key_entry));
        keymap = new_keymap;
 
        return 0;