diff options
-rw-r--r-- | drivers/hid/usbhid/usbkbd.c | 13 | ||||
-rw-r--r-- | drivers/hid/usbhid/usbmouse.c | 15 |
2 files changed, 20 insertions, 8 deletions
diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c index 3749f4a235f9..65aa12e8d7b3 100644 --- a/drivers/hid/usbhid/usbkbd.c +++ b/drivers/hid/usbhid/usbkbd.c | |||
@@ -228,6 +228,7 @@ static int usb_kbd_probe(struct usb_interface *iface, | |||
228 | struct usb_kbd *kbd; | 228 | struct usb_kbd *kbd; |
229 | struct input_dev *input_dev; | 229 | struct input_dev *input_dev; |
230 | int i, pipe, maxp; | 230 | int i, pipe, maxp; |
231 | int error = -ENOMEM; | ||
231 | 232 | ||
232 | interface = iface->cur_altsetting; | 233 | interface = iface->cur_altsetting; |
233 | 234 | ||
@@ -306,15 +307,19 @@ static int usb_kbd_probe(struct usb_interface *iface, | |||
306 | kbd->led->transfer_dma = kbd->leds_dma; | 307 | kbd->led->transfer_dma = kbd->leds_dma; |
307 | kbd->led->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); | 308 | kbd->led->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); |
308 | 309 | ||
309 | input_register_device(kbd->dev); | 310 | error = input_register_device(kbd->dev); |
311 | if (error) | ||
312 | goto fail2; | ||
310 | 313 | ||
311 | usb_set_intfdata(iface, kbd); | 314 | usb_set_intfdata(iface, kbd); |
312 | return 0; | 315 | return 0; |
313 | 316 | ||
314 | fail2: usb_kbd_free_mem(dev, kbd); | 317 | fail2: |
315 | fail1: input_free_device(input_dev); | 318 | usb_kbd_free_mem(dev, kbd); |
319 | fail1: | ||
320 | input_free_device(input_dev); | ||
316 | kfree(kbd); | 321 | kfree(kbd); |
317 | return -ENOMEM; | 322 | return error; |
318 | } | 323 | } |
319 | 324 | ||
320 | static void usb_kbd_disconnect(struct usb_interface *intf) | 325 | static void usb_kbd_disconnect(struct usb_interface *intf) |
diff --git a/drivers/hid/usbhid/usbmouse.c b/drivers/hid/usbhid/usbmouse.c index 692fd6087779..573776d865e1 100644 --- a/drivers/hid/usbhid/usbmouse.c +++ b/drivers/hid/usbhid/usbmouse.c | |||
@@ -120,6 +120,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i | |||
120 | struct usb_mouse *mouse; | 120 | struct usb_mouse *mouse; |
121 | struct input_dev *input_dev; | 121 | struct input_dev *input_dev; |
122 | int pipe, maxp; | 122 | int pipe, maxp; |
123 | int error = -ENOMEM; | ||
123 | 124 | ||
124 | interface = intf->cur_altsetting; | 125 | interface = intf->cur_altsetting; |
125 | 126 | ||
@@ -188,15 +189,21 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i | |||
188 | mouse->irq->transfer_dma = mouse->data_dma; | 189 | mouse->irq->transfer_dma = mouse->data_dma; |
189 | mouse->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 190 | mouse->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
190 | 191 | ||
191 | input_register_device(mouse->dev); | 192 | error = input_register_device(mouse->dev); |
193 | if (error) | ||
194 | goto fail3; | ||
192 | 195 | ||
193 | usb_set_intfdata(intf, mouse); | 196 | usb_set_intfdata(intf, mouse); |
194 | return 0; | 197 | return 0; |
195 | 198 | ||
196 | fail2: usb_buffer_free(dev, 8, mouse->data, mouse->data_dma); | 199 | fail3: |
197 | fail1: input_free_device(input_dev); | 200 | usb_free_urb(mouse->irq); |
201 | fail2: | ||
202 | usb_buffer_free(dev, 8, mouse->data, mouse->data_dma); | ||
203 | fail1: | ||
204 | input_free_device(input_dev); | ||
198 | kfree(mouse); | 205 | kfree(mouse); |
199 | return -ENOMEM; | 206 | return error; |
200 | } | 207 | } |
201 | 208 | ||
202 | static void usb_mouse_disconnect(struct usb_interface *intf) | 209 | static void usb_mouse_disconnect(struct usb_interface *intf) |