linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: roccat: Use kmemdup rather than duplicating its implementation
@ 2011-11-17 22:43 Thomas Meyer
  2011-11-19 23:43 ` Jiri Kosina
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Meyer @ 2011-11-17 22:43 UTC (permalink / raw)
  To: jkosina, linux-input, linux-kernel

The semantic patch that makes this change is available
in scripts/coccinelle/api/memdup.cocci.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/drivers/hid/hid-roccat-common.c b/drivers/hid/hid-roccat-common.c
--- a/drivers/hid/hid-roccat-common.c 2011-11-07 19:39:05.364461084 +0100
+++ b/drivers/hid/hid-roccat-common.c 2011-11-08 10:45:42.781966362 +0100
@@ -49,12 +49,10 @@ int roccat_common_send(struct usb_device
 	char *buf;
 	int len;
 
-	buf = kmalloc(size, GFP_KERNEL);
+	buf = kmemdup(data, size, GFP_KERNEL);
 	if (buf == NULL)
 		return -ENOMEM;
 
-	memcpy(buf, data, size);
-
 	len = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
 			HID_REQ_SET_REPORT,
 			USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
diff -u -p a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c
--- a/drivers/hid/hid-roccat-kone.c 2011-11-07 19:37:44.826571091 +0100
+++ b/drivers/hid/hid-roccat-kone.c 2011-11-08 10:45:45.085330572 +0100
@@ -78,12 +78,10 @@ static int kone_send(struct usb_device *
 	char *buf;
 	int len;
 
-	buf = kmalloc(size, GFP_KERNEL);
+	buf = kmemdup(data, size, GFP_KERNEL);
 	if (buf == NULL)
 		return -ENOMEM;
 
-	memcpy(buf, data, size);
-
 	len = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
 			HID_REQ_SET_REPORT,
 			USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] HID: roccat: Use kmemdup rather than duplicating its implementation
  2011-11-17 22:43 [PATCH] HID: roccat: Use kmemdup rather than duplicating its implementation Thomas Meyer
@ 2011-11-19 23:43 ` Jiri Kosina
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2011-11-19 23:43 UTC (permalink / raw)
  To: Thomas Meyer; +Cc: linux-input, linux-kernel

On Thu, 17 Nov 2011, Thomas Meyer wrote:

> The semantic patch that makes this change is available
> in scripts/coccinelle/api/memdup.cocci.
> 
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
> ---
> 
> diff -u -p a/drivers/hid/hid-roccat-common.c b/drivers/hid/hid-roccat-common.c
> --- a/drivers/hid/hid-roccat-common.c 2011-11-07 19:39:05.364461084 +0100
> +++ b/drivers/hid/hid-roccat-common.c 2011-11-08 10:45:42.781966362 +0100
> @@ -49,12 +49,10 @@ int roccat_common_send(struct usb_device
>  	char *buf;
>  	int len;
>  
> -	buf = kmalloc(size, GFP_KERNEL);
> +	buf = kmemdup(data, size, GFP_KERNEL);
>  	if (buf == NULL)
>  		return -ENOMEM;
>  
> -	memcpy(buf, data, size);
> -
>  	len = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
>  			HID_REQ_SET_REPORT,
>  			USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
> diff -u -p a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c
> --- a/drivers/hid/hid-roccat-kone.c 2011-11-07 19:37:44.826571091 +0100
> +++ b/drivers/hid/hid-roccat-kone.c 2011-11-08 10:45:45.085330572 +0100
> @@ -78,12 +78,10 @@ static int kone_send(struct usb_device *
>  	char *buf;
>  	int len;
>  
> -	buf = kmalloc(size, GFP_KERNEL);
> +	buf = kmemdup(data, size, GFP_KERNEL);
>  	if (buf == NULL)
>  		return -ENOMEM;
>  
> -	memcpy(buf, data, size);
> -
>  	len = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
>  			HID_REQ_SET_REPORT,
>  			USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,

Applied, thank you.

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-11-19 23:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-17 22:43 [PATCH] HID: roccat: Use kmemdup rather than duplicating its implementation Thomas Meyer
2011-11-19 23:43 ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).