Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761513Ab3DBJXa (ORCPT ); Tue, 2 Apr 2013 05:23:30 -0400 Received: from cantor2.suse.de ([195.135.220.15]:56327 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754310Ab3DBJX2 (ORCPT ); Tue, 2 Apr 2013 05:23:28 -0400 Date: Tue, 02 Apr 2013 11:23:24 +0200 Message-ID: From: Takashi Iwai To: Alexandru Gheorghiu Cc: Jaroslav Kysela , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] sound: oss: uart401: Used kmemdup instead of kmalloc and memcpy In-Reply-To: <1364219209-11807-1-git-send-email-gheorghiuandru@gmail.com> References: <1364219209-11807-1-git-send-email-gheorghiuandru@gmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/24.2 (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 Content-Length: 2158 Lines: 61 At Mon, 25 Mar 2013 15:46:49 +0200, Alexandru Gheorghiu wrote: > > Used kmemdup instead of replicating it's behaviour with kmalloc followed > by memcpy. > Patch found using coccinelle. > > Signed-off-by: Alexandru Gheorghiu Thanks, applied. Takashi > --- > sound/oss/uart401.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/sound/oss/uart401.c b/sound/oss/uart401.c > index 8e514a6..5433c6f 100644 > --- a/sound/oss/uart401.c > +++ b/sound/oss/uart401.c > @@ -352,23 +352,26 @@ int probe_uart401(struct address_info *hw_config, struct module *owner) > goto cleanup_irq; > } > conf_printf(name, hw_config); > - midi_devs[devc->my_dev] = kmalloc(sizeof(struct midi_operations), GFP_KERNEL); > + midi_devs[devc->my_dev] = kmemdup(&uart401_operations, > + sizeof(struct midi_operations), > + GFP_KERNEL); > if (!midi_devs[devc->my_dev]) { > printk(KERN_ERR "uart401: Failed to allocate memory\n"); > goto cleanup_unload_mididev; > } > - memcpy(midi_devs[devc->my_dev], &uart401_operations, sizeof(struct midi_operations)); > > if (owner) > midi_devs[devc->my_dev]->owner = owner; > > midi_devs[devc->my_dev]->devc = devc; > - midi_devs[devc->my_dev]->converter = kmalloc(sizeof(struct synth_operations), GFP_KERNEL); > + midi_devs[devc->my_dev]->converter = kmemdup(&std_midi_synth, > + sizeof(struct synth_operations), > + GFP_KERNEL); > + > if (!midi_devs[devc->my_dev]->converter) { > printk(KERN_WARNING "uart401: Failed to allocate memory\n"); > goto cleanup_midi_devs; > } > - memcpy(midi_devs[devc->my_dev]->converter, &std_midi_synth, sizeof(struct synth_operations)); > strcpy(midi_devs[devc->my_dev]->info.name, name); > midi_devs[devc->my_dev]->converter->id = "UART401"; > midi_devs[devc->my_dev]->converter->midi_dev = devc->my_dev; > -- > 1.7.9.5 > -- 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/