Explorar o código

USB: Realtek cr: Use kmemdup rather than duplicating its implementation

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>
Thomas Meyer %!s(int64=13) %!d(string=hai) anos
pai
achega
eb54552294
Modificáronse 1 ficheiros con 1 adicións e 2 borrados
  1. 1 2
      drivers/usb/storage/realtek_cr.c

+ 1 - 2
drivers/usb/storage/realtek_cr.c

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