Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1403763 > unrolled thread

[PATCH] net: usb: ch9200: use kmemdup

Started byMuhammad Falak R Wani <falakreyaz@gmail.com>
First post2016-05-19 16:00 +0200
Last post2016-05-21 02:00 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] net: usb: ch9200: use kmemdup Muhammad Falak R Wani <falakreyaz@gmail.com> - 2016-05-19 16:00 +0200
    Re: [PATCH] net: usb: ch9200: use kmemdup David Miller <davem@davemloft.net> - 2016-05-21 02:00 +0200

#1403763 — [PATCH] net: usb: ch9200: use kmemdup

FromMuhammad Falak R Wani <falakreyaz@gmail.com>
Date2016-05-19 16:00 +0200
Subject[PATCH] net: usb: ch9200: use kmemdup
Message-ID<rAwEy-vI-31@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1404774

FromDavid Miller <davem@davemloft.net>
Date2016-05-21 02:00 +0200
Message-ID<rB2uJ-4fX-11@gated-at.bofh.it>
In reply to#1403763
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.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web