USB: fix memory leak in berry_charge driver
authorGreg Kroah-Hartman <gregkh@suse.de>
Thu, 23 Aug 2007 22:55:34 +0000 (15:55 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 12 Oct 2007 21:55:20 +0000 (14:55 -0700)
This fixes a small memory leak that happens every time the device is
plugged in.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/misc/berry_charge.c

index 92c1d2768df9680afb7050d74b09b30c10db1d65..24e2dc3148a492d6b1adaf40a484b21717ae72bd 100644 (file)
@@ -71,7 +71,7 @@ static int magic_charge(struct usb_device *udev)
        if (retval != 2) {
                dev_err(&udev->dev, "First magic command failed: %d.\n",
                        retval);
-               return retval;
+               goto exit;
        }
 
        dbg(&udev->dev, "Sending second magic command\n");
@@ -80,7 +80,7 @@ static int magic_charge(struct usb_device *udev)
        if (retval != 0) {
                dev_err(&udev->dev, "Second magic command failed: %d.\n",
                        retval);
-               return retval;
+               goto exit;
        }
 
        dbg(&udev->dev, "Calling set_configuration\n");
@@ -88,6 +88,8 @@ static int magic_charge(struct usb_device *udev)
        if (retval)
                dev_err(&udev->dev, "Set Configuration failed :%d.\n", retval);
 
+exit:
+       kfree(dummy_buffer);
        return retval;
 }
 
@@ -112,6 +114,7 @@ static int magic_dual_mode(struct usb_device *udev)
        if (retval)
                dev_err(&udev->dev, "Set Configuration failed :%d.\n", retval);
 
+       kfree(dummy_buffer);
        return retval;
 }