Skip to contentSkip to conversation

Staging: speakup: Use kmemdup rather than duplicating its implementation

PATCH New Thomas Meyer 1 participant 1 message Nov 12, 2011 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: speakup: Use kmemdup rather than duplicating its implementation

Use kmemdup rather than duplicating its implementation

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

---

drivers/staging/speakup/kobjects.c 2011-11-08 10:52:31.467444789 +0100 renamed from drivers/staging/speakup/kobjects.c 2011-11-07 19:38:12.073651604 +0100 +1 -2
diff -u -p a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
@@ -265,12 +265,11 @@ static ssize_t keymap_store(struct kobje
 	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");