Re: [patch] hid: check for kmalloc() failure

From
Stefan Achatz <erazor_de@users.sourceforge.net>
Date
2011-01-24 18:44:43
Also in
linux-input
Reply to
Dan Carpenter, 2011-01-24
Am Montag, den 24.01.2011, 21:32 +0300 schrieb Dan Carpenter:
quoted hunk ↗ jump to hunk
Return -ENOMEM if kmalloc() fails.

Signed-off-by: Dan Carpenter <redacted>
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
Thread (2 messages) 2 messages, 2 authors, last reply 2011-01-24
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help