Skip to contentSkip to conversation

w1: ds2490: use kmemdup rather than duplicating its implementation

PATCH In review Wei Yongjun 2 participants 2 messages Feb 9, 2017 – Feb 10, 2017 W1 dallas's 1-wire bus

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 w1: ds2490: use kmemdup rather than duplicating its implementation

From: Wei Yongjun <[email protected]>

Use kmemdup rather than duplicating its implementation.

Generated by: scripts/coccinelle/api/memdup.cocci

---
 drivers/w1/masters/ds2490.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/w1/masters/ds2490.c +1 -2
index 59d74d1..be77b79 100644
@@ -909,11 +909,10 @@ static void ds9490r_write_block(void *data, const u8 *buf, int len)
 	if (len <= 0)
 		return;
 
-	tbuf = kmalloc(len, GFP_KERNEL);
+	tbuf = kmemdup(buf, len, GFP_KERNEL);
 	if (!tbuf)
 		return;
 
-	memcpy(tbuf, buf, len);
 	ds_write_block(dev, tbuf, len);
 
 	kfree(tbuf);