USB HID: usbkbd/usbmouse - handle errors when registering devices
Handle errors when registering input devices in usbkbd/usbmouse.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c
index 3749f4a..65aa12e8 100644
--- a/drivers/hid/usbhid/usbkbd.c
+++ b/drivers/hid/usbhid/usbkbd.c
@@ -228,6 +228,7 @@
struct usb_kbd *kbd;
struct input_dev *input_dev;
int i, pipe, maxp;
+ int error = -ENOMEM;
interface = iface->cur_altsetting;
@@ -306,15 +307,19 @@
kbd->led->transfer_dma = kbd->leds_dma;
kbd->led->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP);
- input_register_device(kbd->dev);
+ error = input_register_device(kbd->dev);
+ if (error)
+ goto fail2;
usb_set_intfdata(iface, kbd);
return 0;
-fail2: usb_kbd_free_mem(dev, kbd);
-fail1: input_free_device(input_dev);
+fail2:
+ usb_kbd_free_mem(dev, kbd);
+fail1:
+ input_free_device(input_dev);
kfree(kbd);
- return -ENOMEM;
+ return error;
}
static void usb_kbd_disconnect(struct usb_interface *intf)