staging: gdm72xx: fix memory leak
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>
Mon, 7 Sep 2015 12:38:21 +0000 (18:08 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 13 Sep 2015 01:24:53 +0000 (18:24 -0700)
We were successfully requesting the firmware but on error it was not
being released.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/gdm72xx/usb_boot.c

index 3ccc447730e88b23206e261745ffadfd4d01585e..50fbec3ecf1f56c8db844c108da1de2da6d1ca89 100644 (file)
@@ -159,8 +159,10 @@ int usb_boot(struct usb_device *usbdev, u16 pid)
        }
 
        tx_buf = kmalloc(DOWNLOAD_SIZE, GFP_KERNEL);
-       if (tx_buf == NULL)
+       if (tx_buf == NULL) {
+               release_firmware(firm);
                return -ENOMEM;
+       }
 
        if (firm->size < sizeof(hdr)) {
                dev_err(&usbdev->dev, "Cannot read the image info.\n");
@@ -285,8 +287,10 @@ static int em_download_image(struct usb_device *usbdev, const char *img_name,
        }
 
        buf = kmalloc(DOWNLOAD_CHUCK + pad_size, GFP_KERNEL);
-       if (buf == NULL)
+       if (buf == NULL) {
+               release_firmware(firm);
                return -ENOMEM;
+       }
 
        strcpy(buf+pad_size, type_string);
        ret = gdm_wibro_send(usbdev, buf, strlen(type_string)+pad_size);