[media] smscoreapi: memory leak fix
authorRoberto Alcântara <roberto@eletronica.org>
Tue, 21 May 2013 19:32:30 +0000 (16:32 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Thu, 13 Jun 2013 12:00:45 +0000 (09:00 -0300)
Ensure release_firmware is called if kmalloc fails.

[mchehab@redhat.com: patch unmangled and converted from -p2 to -p1]
Signed-off-by: Roberto Alcantara <roberto@eletronica.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/common/siano/smscoreapi.c

index dbe9b4d9b7991c1d130472661f37c57cf8c7af42..a142f7942a015c86da5a72f7401232c58a0ffe0f 100644 (file)
@@ -1173,15 +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 = -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);
+               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);