From: Takashi Iwai <tiwai@suse.de>
To: Alexandru Gheorghiu <gheorghiuandru@gmail.com>
Cc: Jaroslav Kysela <perex@perex.cz>,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sound: oss: uart401: Used kmemdup instead of kmalloc and memcpy
Date: Tue, 02 Apr 2013 11:23:24 +0200 [thread overview]
Message-ID: <s5hmwth8ewj.wl%tiwai@suse.de> (raw)
In-Reply-To: <1364219209-11807-1-git-send-email-gheorghiuandru@gmail.com>
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 <gheorghiuandru@gmail.com>
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
>
prev parent reply other threads:[~2013-04-02 9:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-25 13:46 [PATCH] sound: oss: uart401: Used kmemdup instead of kmalloc and memcpy Alexandru Gheorghiu
2013-04-02 9:23 ` Takashi Iwai [this message]
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=s5hmwth8ewj.wl%tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=gheorghiuandru@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
/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