diff options
author | Dmitry Torokhov <dtor@mail.ru> | 2007-04-04 04:40:57 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2007-04-11 04:36:03 -0400 |
commit | 5d6341c606b9eb62fbaa7b2a0da82ac851bf0fc4 (patch) | |
tree | 5ab2882f7b524ba20dab60957ab2d8176fc9890c /drivers/hid/usbhid/usbmouse.c | |
parent | 66df514b1dbf51a0a02a8abe1219e46e49710aea (diff) |
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>
Diffstat (limited to 'drivers/hid/usbhid/usbmouse.c')
-rw-r--r-- | drivers/hid/usbhid/usbmouse.c | 15 |
1 files changed, 11 insertions, 4 deletions
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) |