Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=5d6341c606b9eb62fbaa7b2a0da82ac851bf0fc4
Commit:     5d6341c606b9eb62fbaa7b2a0da82ac851bf0fc4
Parent:     66df514b1dbf51a0a02a8abe1219e46e49710aea
Author:     Dmitry Torokhov <[EMAIL PROTECTED]>
AuthorDate: Wed Apr 4 10:40:57 2007 +0200
Committer:  Jiri Kosina <[EMAIL PROTECTED]>
CommitDate: Wed Apr 11 10:36:03 2007 +0200

    USB HID: usbkbd/usbmouse - handle errors when registering devices
    
    Handle errors when registering input devices in usbkbd/usbmouse.
    
    Signed-off-by: Dmitry Torokhov <[EMAIL PROTECTED]>
    Signed-off-by: Jiri Kosina <[EMAIL PROTECTED]>
---
 drivers/hid/usbhid/usbkbd.c   |   13 +++++++++----
 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 3749f4a..65aa12e 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,
        struct usb_kbd *kbd;
        struct input_dev *input_dev;
        int i, pipe, maxp;
+       int error = -ENOMEM;
 
        interface = iface->cur_altsetting;
 
@@ -306,15 +307,19 @@ static int usb_kbd_probe(struct usb_interface *iface,
        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)
diff --git a/drivers/hid/usbhid/usbmouse.c b/drivers/hid/usbhid/usbmouse.c
index 692fd60..573776d 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
        struct usb_mouse *mouse;
        struct input_dev *input_dev;
        int pipe, maxp;
+       int error = -ENOMEM;
 
        interface = intf->cur_altsetting;
 
@@ -188,15 +189,21 @@ static int usb_mouse_probe(struct usb_interface *intf, 
const struct usb_device_i
        mouse->irq->transfer_dma = mouse->data_dma;
        mouse->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
 
-       input_register_device(mouse->dev);
+       error = input_register_device(mouse->dev);
+       if (error)
+               goto fail3;
 
        usb_set_intfdata(intf, mouse);
        return 0;
 
-fail2: usb_buffer_free(dev, 8, mouse->data, mouse->data_dma);
-fail1: input_free_device(input_dev);
+fail3: 
+       usb_free_urb(mouse->irq);
+fail2: 
+       usb_buffer_free(dev, 8, mouse->data, mouse->data_dma);
+fail1: 
+       input_free_device(input_dev);
        kfree(mouse);
-       return -ENOMEM;
+       return error;
 }
 
 static void usb_mouse_disconnect(struct usb_interface *intf)
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to