aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/input/xpad.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@insightbb.com>2007-04-12 01:33:39 -0400
committerDmitry Torokhov <dtor@insightbb.com>2007-04-12 01:33:39 -0400
commit5014186de89708d0e9eed60526b698d5b786b707 (patch)
tree949ea6219db7779f635a34278325bd2d9617c657 /drivers/usb/input/xpad.c
parentdb61a9124880a1d79b7b320d4b6bef717f23e485 (diff)
Input: USB devices - handle errors when registering input devices
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/usb/input/xpad.c')
-rw-r--r--drivers/usb/input/xpad.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c
index e4bc76ebc835..ca03d1fc233f 100644
--- a/drivers/usb/input/xpad.c
+++ b/drivers/usb/input/xpad.c
@@ -312,6 +312,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
312 struct input_dev *input_dev; 312 struct input_dev *input_dev;
313 struct usb_endpoint_descriptor *ep_irq_in; 313 struct usb_endpoint_descriptor *ep_irq_in;
314 int i; 314 int i;
315 int error = -ENOMEM;
315 316
316 for (i = 0; xpad_device[i].idVendor; i++) { 317 for (i = 0; xpad_device[i].idVendor; i++) {
317 if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && 318 if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) &&
@@ -373,15 +374,18 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
373 xpad->irq_in->transfer_dma = xpad->idata_dma; 374 xpad->irq_in->transfer_dma = xpad->idata_dma;
374 xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 375 xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
375 376
376 input_register_device(xpad->dev); 377 error = input_register_device(xpad->dev);
378 if (error)
379 goto fail3;
377 380
378 usb_set_intfdata(intf, xpad); 381 usb_set_intfdata(intf, xpad);
379 return 0; 382 return 0;
380 383
381fail2: usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); 384 fail3: usb_free_urb(xpad->irq_in);
382fail1: input_free_device(input_dev); 385 fail2: usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma);
386 fail1: input_free_device(input_dev);
383 kfree(xpad); 387 kfree(xpad);
384 return -ENOMEM; 388 return error;
385 389
386} 390}
387 391