Skip to contentSkip to conversation

aoe: replace kmalloc and then memcpy with kmemdup

PATCH In review Mihnea Dobrescu-Balaur 2 participants 2 messages Mar 11, 2013

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

PATCH 1/1 aoe: replace kmalloc and then memcpy with kmemdup

---
 drivers/block/aoe/aoechr.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/block/aoe/aoechr.c +1 -2
index 42e67ad..ab41be6 100644
@@ -139,13 +139,12 @@ bail:		spin_unlock_irqrestore(&emsgs_lock, flags);
 		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;
Signature · 1 line
1.7.10.4
#1 lore raw

Looks OK, thanks.

Quoted 27 lines · Mihnea Dobrescu-Balaur

---
drivers/block/aoe/aoechr.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
drivers/block/aoe/aoechr.c +1 -2
index 42e67ad..ab41be6 100644
@@ -139,13 +139,12 @@ bail:		spin_unlock_irqrestore(&emsgs_lock, flags);
 		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;
Signature · 1 line
1.7.10.4
Signature · 2 lines
  Ed Cashin
  [email protected]