From 36b51146539c42306fd6ab1ff30cfc5a2d13c706 Mon Sep 17 00:00:00 2001 From: Roberto Alcântara Date: Tue, 21 May 2013 16:32:30 -0300 Subject: [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 Signed-off-by: Mauro Carvalho Chehab --- drivers/media/common/siano/smscoreapi.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'drivers/media/common/siano') 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); -- cgit v1.2.3