Skip to content

Commit

Permalink
r8152: Use kmemdup instead of kmalloc + memcpy
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Benoit Taine authored and David S. Miller committed May 30, 2014
1 parent 958c492 commit c4438f0
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/net/usb/r8152.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c4438f0

Please sign in to comment.