Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752722AbbKYQTc (ORCPT ); Wed, 25 Nov 2015 11:19:32 -0500 Received: from canardo.mork.no ([148.122.252.1]:48590 "EHLO canardo.mork.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751726AbbKYQTa convert rfc822-to-8bit (ORCPT ); Wed, 25 Nov 2015 11:19:30 -0500 From: =?utf-8?Q?Bj=C3=B8rn_Mork?= To: Anup Limbu 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 Organization: m References: <1448446041-15663-1-git-send-email-anuplimbu14@gmail.com> Date: Wed, 25 Nov 2015 17:19:12 +0100 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") Message-ID: <87mvu2vypr.fsf@nemi.mork.no> User-Agent: Gnus/5.130013 (Ma Gnus v0.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1162 Lines: 41 Anup Limbu writes: > replace kmalloc + memset with kmemdup > > Signed-off-by: Anup Limbu > --- > 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/