]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
drivers/memstick: use kmemdup rather than duplicating its implementation
authorThomas Meyer <thomas@m3y3r.de>
Thu, 8 Dec 2011 04:42:56 +0000 (15:42 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 13 Dec 2011 06:43:38 +0000 (17:43 +1100)
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 <thomas@m3y3r.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/memstick/core/mspro_block.c

index 9729b92fbfdd3150280328a2be3d5872beacd618..b4a273f5f1b1df6c27d638694d6ae951c5bf303e 100644 (file)
@@ -1034,12 +1034,11 @@ static int mspro_block_read_attributes(struct memstick_dev *card)
        }
        msb->attr_group.name = "media_attributes";
 
-       buffer = kmalloc(attr_len, GFP_KERNEL);
+       buffer = kmemdup((char *)attr, attr_len, GFP_KERNEL);
        if (!buffer) {
                rc = -ENOMEM;
                goto out_free_attr;
        }
-       memcpy(buffer, (char *)attr, attr_len);
 
        for (cnt = 0; cnt < attr_count; ++cnt) {
                s_attr = kzalloc(sizeof(struct mspro_sys_attr), GFP_KERNEL);