]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
USB: Fix unload oops and memory leak in yealink driver
authorHenk Vergonet <henk.vergonet@gmail.com>
Fri, 22 Sep 2006 18:20:40 +0000 (20:20 +0200)
committerAdrian Bunk <bunk@stusta.de>
Fri, 22 Sep 2006 18:20:40 +0000 (20:20 +0200)
This patch fixes a memory leak and a kernel oops when trying to unload
the driver, due to an unbalanced cleanup.
Thanks Ivar Jensen for spotting my mistake.

Signed-off-by: Henk Vergonet <henk.vergonet@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
drivers/usb/input/yealink.c

index 37d2f0ba0319c28e73e688394c27c3f65ab28459..b1d4fd662a46cb5bfda42267a8288e5f7e011326 100644 (file)
@@ -813,12 +813,9 @@ static int usb_cleanup(struct yealink_dev *yld, int err)
        if (yld == NULL)
                return err;
 
-        if (yld->urb_irq) {
-               usb_kill_urb(yld->urb_irq);
-               usb_free_urb(yld->urb_irq);
-       }
-        if (yld->urb_ctl)
-               usb_free_urb(yld->urb_ctl);
+       usb_kill_urb(yld->urb_irq);     /* parameter validation in core/urb */
+       usb_kill_urb(yld->urb_ctl);     /* parameter validation in core/urb */
+
         if (yld->idev) {
                if (err)
                        input_free_device(yld->idev);
@@ -834,6 +831,9 @@ static int usb_cleanup(struct yealink_dev *yld, int err)
        if (yld->irq_data)
                usb_buffer_free(yld->udev, USB_PKT_LEN,
                                yld->irq_data, yld->irq_dma);
+
+       usb_free_urb(yld->urb_irq);     /* parameter validation in core/urb */
+       usb_free_urb(yld->urb_ctl);     /* parameter validation in core/urb */
        kfree(yld);
        return err;
 }