diff options
author | Dmitry Torokhov <dtor@insightbb.com> | 2007-04-12 01:33:39 -0400 |
---|---|---|
committer | Dmitry Torokhov <dtor@insightbb.com> | 2007-04-12 01:33:39 -0400 |
commit | 5014186de89708d0e9eed60526b698d5b786b707 (patch) | |
tree | 949ea6219db7779f635a34278325bd2d9617c657 /drivers/usb/input/kbtab.c | |
parent | db61a9124880a1d79b7b320d4b6bef717f23e485 (diff) |
Input: USB devices - handle errors when registering input devices
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/usb/input/kbtab.c')
-rw-r--r-- | drivers/usb/input/kbtab.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c index fedbcb127c21..64da9876fe56 100644 --- a/drivers/usb/input/kbtab.c +++ b/drivers/usb/input/kbtab.c | |||
@@ -122,6 +122,7 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
122 | struct usb_endpoint_descriptor *endpoint; | 122 | struct usb_endpoint_descriptor *endpoint; |
123 | struct kbtab *kbtab; | 123 | struct kbtab *kbtab; |
124 | struct input_dev *input_dev; | 124 | struct input_dev *input_dev; |
125 | int error = -ENOMEM; | ||
125 | 126 | ||
126 | kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL); | 127 | kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL); |
127 | input_dev = input_allocate_device(); | 128 | input_dev = input_allocate_device(); |
@@ -168,15 +169,19 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
168 | kbtab->irq->transfer_dma = kbtab->data_dma; | 169 | kbtab->irq->transfer_dma = kbtab->data_dma; |
169 | kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 170 | kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
170 | 171 | ||
171 | input_register_device(kbtab->dev); | 172 | error = input_register_device(kbtab->dev); |
173 | if (error) | ||
174 | goto fail3; | ||
172 | 175 | ||
173 | usb_set_intfdata(intf, kbtab); | 176 | usb_set_intfdata(intf, kbtab); |
177 | |||
174 | return 0; | 178 | return 0; |
175 | 179 | ||
176 | fail2: usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma); | 180 | fail3: usb_free_urb(kbtab->irq); |
177 | fail1: input_free_device(input_dev); | 181 | fail2: usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma); |
182 | fail1: input_free_device(input_dev); | ||
178 | kfree(kbtab); | 183 | kfree(kbtab); |
179 | return -ENOMEM; | 184 | return error; |
180 | } | 185 | } |
181 | 186 | ||
182 | static void kbtab_disconnect(struct usb_interface *intf) | 187 | static void kbtab_disconnect(struct usb_interface *intf) |