Skip to contentSkip to conversation

aoe: Use kmemdup rather than duplicating its implementation

PATCH New Thomas Meyer 1 participant 1 message Nov 22, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aoe: Use kmemdup rather than duplicating its implementation

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

---

drivers/block/aoe/aoechr.c 2011-11-08 10:37:35.225430670 +0100 renamed from drivers/block/aoe/aoechr.c 2011-11-07 19:39:05.287793252 +0100 +1 -2
diff -u -p a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
@@ -134,13 +134,12 @@ bail:		spin_unlock_irqrestore(&emsgs_loc
 		return;
 	}
 
-	mp = kmalloc(n, GFP_ATOMIC);
+	mp = kmemdup(msg, n, GFP_ATOMIC);
 	if (mp == NULL) {
 		printk(KERN_ERR "aoe: allocation failure, len=%ld\n", n);
 		goto bail;
 	}
 
-	memcpy(mp, msg, n);
 	em->msg = mp;
 	em->flags |= EMFL_VALID;
 	em->len = n;