sound: oss: sb_common: Used kmemdup instead of kmalloc and memcpy
authorAlexandru Gheorghiu <gheorghiuandru@gmail.com>
Mon, 25 Mar 2013 13:50:34 +0000 (15:50 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 2 Apr 2013 09:23:00 +0000 (11:23 +0200)
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>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/oss/sb_common.c

index 7d42c54..851a1da 100644 (file)
@@ -626,13 +626,12 @@ int sb_dsp_detect(struct address_info *hw_config, int pci, int pciio, struct sb_
         */
 
 
-       detected_devc = kmalloc(sizeof(sb_devc), GFP_KERNEL);
+       detected_devc = kmemdup(devc, sizeof(sb_devc), GFP_KERNEL);
        if (detected_devc == NULL)
        {
                printk(KERN_ERR "sb: Can't allocate memory for device information\n");
                return 0;
        }
-       memcpy(detected_devc, devc, sizeof(sb_devc));
        MDB(printk(KERN_INFO "SB %d.%02d detected OK (%x)\n", devc->major, devc->minor, hw_config->io_base));
        return 1;
 }