[PATCH] smscoreapi: memory leak fix

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ensure release_firmware is called if kmalloc fails.

Signed-off-by:Roberto Alcantara <roberto@xxxxxxxxxxxxxx>
diff --git a/linux/drivers/media/common/siano/smscoreapi.c
b/linux/drivers/media/common/siano/smscoreapi.c
index dbe9b4d..f65b4e3 100644
--- a/linux/drivers/media/common/siano/smscoreapi.c
+++ b/linux/drivers/media/common/siano/smscoreapi.c
@@ -1173,16 +1173,16 @@ static int
smscore_load_firmware_from_file(struct smscore_device_t *coredev,
              GFP_KERNEL | GFP_DMA);
     if (!fw_buf) {
         sms_err("failed to allocate firmware buffer");
-        return -ENOMEM;
-    }
-    memcpy(fw_buf, fw->data, fw->size);
-    fw_buf_size = fw->size;
-
-    rc = (coredev->device_flags & SMS_DEVICE_FAMILY2) ?
-        smscore_load_firmware_family2(coredev, fw_buf, fw_buf_size)
-        : loadfirmware_handler(coredev->context, fw_buf,
-        fw_buf_size);
+        rc = -ENOMEM;
+    } else {
+        memcpy(fw_buf, fw->data, fw->size);
+        fw_buf_size = fw->size;

+        rc = (coredev->device_flags & SMS_DEVICE_FAMILY2) ?
+            smscore_load_firmware_family2(coredev, fw_buf, fw_buf_size)
+            : loadfirmware_handler(coredev->context, fw_buf,
+            fw_buf_size);
+    }
     kfree(fw_buf);
     release_firmware(fw);
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux