[media] drxd: Use kmemdup rather than duplicating its implementation
authorThomas Meyer <thomas@m3y3r.de>
Thu, 17 Nov 2011 21:43:40 +0000 (18:43 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Thu, 24 Nov 2011 23:04:51 +0000 (21:04 -0200)
The semantic patch that makes this change is available
in scripts/coccinelle/api/memdup.cocci.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/dvb/frontends/drxd_hard.c

index 88e46f4..beb6775 100644 (file)
@@ -914,14 +914,13 @@ static int load_firmware(struct drxd_state *state, const char *fw_name)
                return -EIO;
        }
 
-       state->microcode = kmalloc(fw->size, GFP_KERNEL);
+       state->microcode = kmemdup(fw->data, fw->size, GFP_KERNEL);
        if (state->microcode == NULL) {
                release_firmware(fw);
                printk(KERN_ERR "drxd: firmware load failure: no memory\n");
                return -ENOMEM;
        }
 
-       memcpy(state->microcode, fw->data, fw->size);
        state->microcode_length = fw->size;
        release_firmware(fw);
        return 0;