w1: ds2490: use kmemdup rather than duplicating its implementation

Use kmemdup rather than duplicating its implementation.

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

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Acked-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Wei Yongjun 2017-02-09 15:45:42 +00:00 committed by Greg Kroah-Hartman
parent 425902f5c8
commit 45003a1e25
1 changed files with 1 additions and 2 deletions

View File

@ -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);