From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933040Ab1KJSxg (ORCPT ); Thu, 10 Nov 2011 13:53:36 -0500 Received: from cantor2.suse.de ([195.135.220.15]:34523 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932132Ab1KJSxb (ORCPT ); Thu, 10 Nov 2011 13:53:31 -0500 Date: Thu, 10 Nov 2011 19:53:30 +0100 Message-ID: From: Takashi Iwai To: Thomas Meyer Cc: Jaroslav Kysela , linux-kernel@vger.kernel.org Subject: Re: [PATCH] ALSA: usb-audio: Use kmemdup rather than duplicating its implementation In-Reply-To: <1320950323.20155.106.camel@localhost.localdomain> References: <1320950323.20155.106.camel@localhost.localdomain> User-Agent: Wanderlust/2.15.6 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.7 Emacs/23.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At Thu, 10 Nov 2011 19:38:43 +0100, Thomas Meyer wrote: > > Use kmemdup rather than duplicating its implementation > > The semantic patch that makes this change is available > in scripts/coccinelle/api/memdup.cocci. > > Signed-off-by: Thomas Meyer Thanks, applied now. Takashi > --- > > diff -u -p a/sound/usb/quirks.c b/sound/usb/quirks.c > --- a/sound/usb/quirks.c 2011-11-07 19:38:37.987378553 +0100 > +++ b/sound/usb/quirks.c 2011-11-08 11:06:23.015258350 +0100 > @@ -137,12 +137,12 @@ static int create_fixed_stream_quirk(str > return -ENOMEM; > } > if (fp->nr_rates > 0) { > - rate_table = kmalloc(sizeof(int) * fp->nr_rates, GFP_KERNEL); > + rate_table = kmemdup(fp->rate_table, > + sizeof(int) * fp->nr_rates, GFP_KERNEL); > if (!rate_table) { > kfree(fp); > return -ENOMEM; > } > - memcpy(rate_table, fp->rate_table, sizeof(int) * fp->nr_rates); > fp->rate_table = rate_table; > } > > @@ -224,10 +224,9 @@ static int create_uaxx_quirk(struct snd_ > if (altsd->bNumEndpoints != 1) > return -ENXIO; > > - fp = kmalloc(sizeof(*fp), GFP_KERNEL); > + fp = kmemdup(&ua_format, sizeof(*fp), GFP_KERNEL); > if (!fp) > return -ENOMEM; > - memcpy(fp, &ua_format, sizeof(*fp)); > > fp->iface = altsd->bInterfaceNumber; > fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; > . >