Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1277151 > unrolled thread
| Started by | Anup Limbu <anuplimbu14@gmail.com> |
|---|---|
| First post | 2015-11-25 11:10 +0100 |
| Last post | 2015-11-30 04:50 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] net: usb: ch9200: use kmemdup instead of kmalloc + memcpy Anup Limbu <anuplimbu14@gmail.com> - 2015-11-25 11:10 +0100
Re: [PATCH] net: usb: ch9200: use kmemdup instead of kmalloc + memcpy Bjørn Mork <bjorn@mork.no> - 2015-11-25 17:20 +0100
Re: [PATCH] net: usb: ch9200: use kmemdup instead of kmalloc + memcpy David Miller <davem@davemloft.net> - 2015-11-30 04:50 +0100
| From | Anup Limbu <anuplimbu14@gmail.com> |
|---|---|
| Date | 2015-11-25 11:10 +0100 |
| Subject | [PATCH] net: usb: ch9200: use kmemdup instead of kmalloc + memcpy |
| Message-ID | <qyFbs-4Ly-15@gated-at.bofh.it> |
replace kmalloc + memset with kmemdup
Signed-off-by: Anup Limbu <anuplimbu14@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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Bjørn Mork <bjorn@mork.no> |
|---|---|
| Date | 2015-11-25 17:20 +0100 |
| Message-ID | <qyKXx-cZ-25@gated-at.bofh.it> |
| In reply to | #1277151 |
Anup Limbu <anuplimbu14@gmail.com> writes:
> replace kmalloc + memset with kmemdup
>
> Signed-off-by: Anup Limbu <anuplimbu14@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,
Would it be better to replace control_read() and control_write() with
the usbnet_read_cmd() and usbnet_write_cmd() if you are going to clean
this up?
Bjørn
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2015-11-30 04:50 +0100 |
| Subject | Re: [PATCH] net: usb: ch9200: use kmemdup instead of kmalloc + memcpy |
| Message-ID | <qAnDr-6D0-1@gated-at.bofh.it> |
| In reply to | #1277151 |
From: Anup Limbu <anuplimbu14@gmail.com> Date: Wed, 25 Nov 2015 15:37:21 +0530 > replace kmalloc + memset with kmemdup > > Signed-off-by: Anup Limbu <anuplimbu14@gmail.com> I agree with Bjorn that this microturfing cleanup misses the real higher level opportunity to use the usbnet_read_cmd() and usbnet_write_cmd() helpers that already exist. Over time I am getting more and more weary of laser focused microscopic cleanups. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web