Staging: speakup: Use kmemdup rather than duplicating its implementation
authorThomas Meyer <thomas@m3y3r.de>
Sat, 12 Nov 2011 12:11:18 +0000 (13:11 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sun, 27 Nov 2011 02:12:56 +0000 (18:12 -0800)
Use kmemdup rather than duplicating its implementation

The semantic patch that makes this change is available
in scripts/coccinelle/api/memdup.cocci.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/speakup/kobjects.c

index 07a7f5432597f4d88719850e15406435b9a9b412..2093896c546bde0f977f6e42a5425fa2f276da4f 100644 (file)
@@ -265,12 +265,11 @@ static ssize_t keymap_store(struct kobject *kobj, struct kobj_attribute *attr,
        unsigned long flags;
 
        spk_lock(flags);
-       in_buff = kmalloc(count + 1, GFP_ATOMIC);
+       in_buff = kmemdup(buf, count + 1, GFP_ATOMIC);
        if (!in_buff) {
                spk_unlock(flags);
                return -ENOMEM;
        }
-       memcpy(in_buff, buf, count + 1);
        if (strchr("dDrR", *in_buff)) {
                set_key_info(key_defaults, key_buf);
                pr_info("keymap set to default values\n");