diff options
author | Benoit Taine <benoit.taine@lip6.fr> | 2014-05-26 11:21:23 -0400 |
---|---|---|
committer | Vladislav Zhurba <vzhurba@nvidia.com> | 2018-02-01 16:58:00 -0500 |
commit | 459de17d561c6c4f13e808621049177d4f0c5b14 (patch) | |
tree | e0b08fa7cb95f4749bb680cc1c5e4817d21d5da5 /drivers/net/usb/r8152_shield.c | |
parent | 0f6360151b61b6a789a81e5764289de591f1480b (diff) |
r8152: Use kmemdup instead of kmalloc + memcpy
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
From http://git.kernel.org/cgit/linux/kernel/git/davem/net.git/commit/?id=c4438f03ca439daa349d93d7102ed36422dfcd7f
Change-Id: I2987a0a992f6fe7a312bd92b84ab3b954dfa81e8
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from upstream commit c4438f03ca439daa349d93d7102ed36422dfcd7f)
Signed-off-by: Aly Hirani <ahirani@nvidia.com>
Reviewed-on: http://git-master/r/553391
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Diffstat (limited to 'drivers/net/usb/r8152_shield.c')
-rw-r--r-- | drivers/net/usb/r8152_shield.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/net/usb/r8152_shield.c b/drivers/net/usb/r8152_shield.c index dd067e534..1c206bec9 100644 --- a/drivers/net/usb/r8152_shield.c +++ b/drivers/net/usb/r8152_shield.c | |||
@@ -667,12 +667,10 @@ int set_registers(struct r8152 *tp, u16 value, u16 index, u16 size, void *data) | |||
667 | int ret; | 667 | int ret; |
668 | void *tmp; | 668 | void *tmp; |
669 | 669 | ||
670 | tmp = kmalloc(size, GFP_KERNEL); | 670 | tmp = kmemdup(data, size, GFP_KERNEL); |
671 | if (!tmp) | 671 | if (!tmp) |
672 | return -ENOMEM; | 672 | return -ENOMEM; |
673 | 673 | ||
674 | memcpy(tmp, data, size); | ||
675 | |||
676 | ret = usb_control_msg(tp->udev, usb_sndctrlpipe(tp->udev, 0), | 674 | ret = usb_control_msg(tp->udev, usb_sndctrlpipe(tp->udev, 0), |
677 | RTL8152_REQ_SET_REGS, RTL8152_REQT_WRITE, | 675 | RTL8152_REQ_SET_REGS, RTL8152_REQT_WRITE, |
678 | value, index, tmp, size, 500); | 676 | value, index, tmp, size, 500); |