summaryrefslogtreecommitdiff
path: root/drivers/media/common
diff options
context:
space:
mode:
authorRoberto Alcântara <roberto@eletronica.org>2013-05-21 16:32:30 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-06-13 09:00:45 -0300
commit36b51146539c42306fd6ab1ff30cfc5a2d13c706 (patch)
treef61f61e71aa3979c73e6a927c65fda6bd180a9c6 /drivers/media/common
parent62d54876c511628daed2246753e2fe348da022f1 (diff)
[media] smscoreapi: memory leak fix
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>
Diffstat (limited to 'drivers/media/common')
-rw-r--r--drivers/media/common/siano/smscoreapi.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c
index dbe9b4d9b799..a142f7942a01 100644
--- a/drivers/media/common/siano/smscoreapi.c
+++ b/drivers/media/common/siano/smscoreapi.c
@@ -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);