* [PATCH] net: usb: ch9200: use kmemdup
@ 2016-05-19 13:56 Muhammad Falak R Wani
2016-05-20 23:50 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Muhammad Falak R Wani @ 2016-05-19 13:56 UTC (permalink / raw)
To: akpm
Cc: Matthew Garrett, David S. Miller, Tobias Klauser, linux-usb,
netdev, linux-kernel
Use kmemdup when some other buffer is immediately copied into allocated
region. It replaces call to allocation followed by memcpy, by a single
call to kmemdup.
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
---
drivers/net/usb/ch9200.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/usb/ch9200.c b/drivers/net/usb/ch9200.c
index 5e151e6..8a40202 100644
--- a/drivers/net/usb/ch9200.c
+++ b/drivers/net/usb/ch9200.c
@@ -155,12 +155,11 @@ static int control_write(struct usbnet *dev, unsigned char request,
index, size);
if (data) {
- buf = kmalloc(size, GFP_KERNEL);
+ buf = kmemdup(data, size, GFP_KERNEL);
if (!buf) {
err = -ENOMEM;
goto err_out;
}
- memcpy(buf, data, size);
}
err = usb_control_msg(dev->udev,
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: usb: ch9200: use kmemdup
2016-05-19 13:56 [PATCH] net: usb: ch9200: use kmemdup Muhammad Falak R Wani
@ 2016-05-20 23:50 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-05-20 23:50 UTC (permalink / raw)
To: falakreyaz; +Cc: akpm, mjg59, tklauser, linux-usb, netdev, linux-kernel
From: Muhammad Falak R Wani <falakreyaz@gmail.com>
Date: Thu, 19 May 2016 19:26:50 +0530
> Use kmemdup when some other buffer is immediately copied into allocated
> region. It replaces call to allocation followed by memcpy, by a single
> call to kmemdup.
>
> Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-05-20 23:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-19 13:56 [PATCH] net: usb: ch9200: use kmemdup Muhammad Falak R Wani
2016-05-20 23:50 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).