Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

r8152: Use kmemdup instead of kmalloc + memcpy

This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci

Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Benoit Taine and committed by
David S. Miller
c4438f03 958c492c

+1 -3
+1 -3
drivers/net/usb/r8152.c
··· 630 630 int ret; 631 631 void *tmp; 632 632 633 - tmp = kmalloc(size, GFP_KERNEL); 633 + tmp = kmemdup(data, size, GFP_KERNEL); 634 634 if (!tmp) 635 635 return -ENOMEM; 636 - 637 - memcpy(tmp, data, size); 638 636 639 637 ret = usb_control_msg(tp->udev, usb_sndctrlpipe(tp->udev, 0), 640 638 RTL8152_REQ_SET_REGS, RTL8152_REQT_WRITE,