linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] hid: check for kmalloc() failure
@ 2011-01-24 18:32 Dan Carpenter
  2011-01-24 18:44 ` Stefan Achatz
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2011-01-24 18:32 UTC (permalink / raw)
  To: Jiri Kosina, erazor_de; +Cc: linux-input, kernel-janitors

Return -ENOMEM if kmalloc() fails.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/hid/hid-roccat-koneplus.c b/drivers/hid/hid-roccat-koneplus.c
index 1608c8d..c27bc91 100644
--- a/drivers/hid/hid-roccat-koneplus.c
+++ b/drivers/hid/hid-roccat-koneplus.c
@@ -220,6 +220,10 @@ static int koneplus_get_startup_profile(struct usb_device *usb_dev)
 	int retval;
 
 	buf = kmalloc(sizeof(struct koneplus_startup_profile), GFP_KERNEL);
+	if (!buf) {
+		retval = -ENOMEM;
+		goto out;
+	}
 
 	retval = koneplus_receive(usb_dev, KONEPLUS_USB_COMMAND_STARTUP_PROFILE,
 			buf, sizeof(struct koneplus_startup_profile));

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

* Re: [patch] hid: check for kmalloc() failure
  2011-01-24 18:32 [patch] hid: check for kmalloc() failure Dan Carpenter
@ 2011-01-24 18:44 ` Stefan Achatz
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Achatz @ 2011-01-24 18:44 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Jiri Kosina, linux-input, kernel-janitors

Am Montag, den 24.01.2011, 21:32 +0300 schrieb Dan Carpenter:
> Return -ENOMEM if kmalloc() fails.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> diff --git a/drivers/hid/hid-roccat-koneplus.c b/drivers/hid/hid-roccat-koneplus.c
> index 1608c8d..c27bc91 100644
> --- a/drivers/hid/hid-roccat-koneplus.c
> +++ b/drivers/hid/hid-roccat-koneplus.c
> @@ -220,6 +220,10 @@ static int koneplus_get_startup_profile(struct usb_device *usb_dev)
>  	int retval;
>  
>  	buf = kmalloc(sizeof(struct koneplus_startup_profile), GFP_KERNEL);
> +	if (!buf) {
> +		retval = -ENOMEM;
> +		goto out;
> +	}
>  
>  	retval = koneplus_receive(usb_dev, KONEPLUS_USB_COMMAND_STARTUP_PROFILE,
>  			buf, sizeof(struct koneplus_startup_profile));

That was already fixed by Vasiliy Kulikov. The patch was applied to the
roccat branch in Jiri Kosinas hid repository
(dacfecdbf3a0a5072984ff8b3c224a48c8461008).
Thank you anyway.
Stefan


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

end of thread, other threads:[~2011-01-24 18:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-24 18:32 [patch] hid: check for kmalloc() failure Dan Carpenter
2011-01-24 18:44 ` Stefan Achatz

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).