aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Taine <benoit.taine@lip6.fr>2014-05-26 17:21:23 +0200
committerDavid S. Miller <davem@davemloft.net>2014-05-30 16:25:15 -0700
commitc4438f03ca439daa349d93d7102ed36422dfcd7f (patch)
tree331e736ee045f1cd5f684d7d8ce5fc342faa1202
parentenic: Fix 64 bit divide on 32bit system (diff)
downloadlinux-dev-c4438f03ca439daa349d93d7102ed36422dfcd7f.tar.xz
linux-dev-c4438f03ca439daa349d93d7102ed36422dfcd7f.zip
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>
-rw-r--r--drivers/net/usb/r8152.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 9f91c7aba4b0..25431965a625 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -630,12 +630,10 @@ int set_registers(struct r8152 *tp, u16 value, u16 index, u16 size, void *data)
int ret;
void *tmp;
- tmp = kmalloc(size, GFP_KERNEL);
+ tmp = kmemdup(data, size, GFP_KERNEL);
if (!tmp)
return -ENOMEM;
- memcpy(tmp, data, size);
-
ret = usb_control_msg(tp->udev, usb_sndctrlpipe(tp->udev, 0),
RTL8152_REQ_SET_REGS, RTL8152_REQT_WRITE,
value, index, tmp, size, 500);