Commit 36b51146 authored by Roberto Alcântara's avatar Roberto Alcântara Committed by Mauro Carvalho Chehab

[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: default avatarRoberto Alcantara <roberto@eletronica.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 62d54876
...@@ -1173,8 +1173,8 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev, ...@@ -1173,8 +1173,8 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
GFP_KERNEL | GFP_DMA); GFP_KERNEL | GFP_DMA);
if (!fw_buf) { if (!fw_buf) {
sms_err("failed to allocate firmware buffer"); sms_err("failed to allocate firmware buffer");
return -ENOMEM; rc = -ENOMEM;
} } else {
memcpy(fw_buf, fw->data, fw->size); memcpy(fw_buf, fw->data, fw->size);
fw_buf_size = fw->size; fw_buf_size = fw->size;
...@@ -1182,6 +1182,7 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev, ...@@ -1182,6 +1182,7 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
smscore_load_firmware_family2(coredev, fw_buf, fw_buf_size) smscore_load_firmware_family2(coredev, fw_buf, fw_buf_size)
: loadfirmware_handler(coredev->context, fw_buf, : loadfirmware_handler(coredev->context, fw_buf,
fw_buf_size); fw_buf_size);
}
kfree(fw_buf); kfree(fw_buf);
release_firmware(fw); release_firmware(fw);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment