netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anup Limbu <anuplimbu14@gmail.com>
To: davem@davemloft.net, mjg59@srcf.ucam.org, tklauser@distanz.com,
	linux-usb@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Anup Limbu <anuplimbu14@gmail.com>
Subject: [PATCH] net: usb: ch9200: use kmemdup instead of kmalloc + memcpy
Date: Wed, 25 Nov 2015 15:37:21 +0530	[thread overview]
Message-ID: <1448446041-15663-1-git-send-email-anuplimbu14@gmail.com> (raw)

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

             reply	other threads:[~2015-11-25 10:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-25 10:07 Anup Limbu [this message]
2015-11-25 16:19 ` [PATCH] net: usb: ch9200: use kmemdup instead of kmalloc + memcpy Bjørn Mork
     [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=1448446041-15663-1-git-send-email-anuplimbu14@gmail.com \
    --to=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).