lkml.org 
[lkml]   [2017]   [Feb]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH -next] w1: ds2490: use kmemdup rather than duplicating its implementation
Date
From: Wei Yongjun <weiyongjun1@huawei.com>

Use kmemdup rather than duplicating its implementation.

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

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
drivers/w1/masters/ds2490.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index 59d74d1..be77b79 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -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);
\
 
 \ /
  Last update: 2017-02-09 16:47    [W:0.040 / U:0.480 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site