From: Roberto Alcântara Date: Tue, 21 May 2013 19:32:30 +0000 (-0300) Subject: [media] smscoreapi: memory leak fix X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=36b51146539c42306fd6ab1ff30cfc5a2d13c706;p=openwrt%2Fstaging%2Fblogic.git [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 --- 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);