netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Bjørn Mork" <bjorn@mork.no>
To: Anup Limbu <anuplimbu14@gmail.com>
Cc: davem@davemloft.net, mjg59@srcf.ucam.org, tklauser@distanz.com,
	linux-usb@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: usb: ch9200: use kmemdup instead of kmalloc + memcpy
Date: Wed, 25 Nov 2015 17:19:12 +0100	[thread overview]
Message-ID: <87mvu2vypr.fsf@nemi.mork.no> (raw)
In-Reply-To: <1448446041-15663-1-git-send-email-anuplimbu14@gmail.com> (Anup Limbu's message of "Wed, 25 Nov 2015 15:37:21 +0530")

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

  reply	other threads:[~2015-11-25 16:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-25 10:07 [PATCH] net: usb: ch9200: use kmemdup instead of kmalloc + memcpy Anup Limbu
2015-11-25 16:19 ` Bjørn Mork [this message]
     [not found] ` <1448446041-15663-1-git-send-email-anuplimbu14-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-30  3:40   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mvu2vypr.fsf@nemi.mork.no \
    --to=bjorn@mork.no \
    --cc=anuplimbu14@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=netdev@vger.kernel.org \
    --cc=tklauser@distanz.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).