USB: Realtek cr: Use kmemdup rather than duplicating its implementation
authorThomas Meyer <thomas@m3y3r.de>
Thu, 10 Nov 2011 18:27:42 +0000 (19:27 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 15 Nov 2011 18:21:55 +0000 (10:21 -0800)
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: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/storage/realtek_cr.c

index 30f64bfe101edc774a8194882682c254af9e85e9..71147679cb1168ae2084ebe4aa7b8f85f216b557 100644 (file)
@@ -398,10 +398,9 @@ static int rts51x_write_mem(struct us_data *us, u16 addr, u8 *data, u16 len)
        u8 cmnd[12] = { 0 };
        u8 *buf;
 
-       buf = kmalloc(len, GFP_NOIO);
+       buf = kmemdup(data, len, GFP_NOIO);
        if (buf == NULL)
                return USB_STOR_TRANSPORT_ERROR;
-       memcpy(buf, data, len);
 
        US_DEBUGP("%s, addr = 0x%x, len = %d\n", __func__, addr, len);