Commit dc889f18 authored by Jesper Juhl's avatar Jesper Juhl Committed by Takashi Iwai

ALSA: asihpi - Don't leak firmware if mem alloc fails

We leak the memory allocated to 'firmware' when we fail to
release_firmware() after a kmalloc() failure in hpi_dsp_code_open().
This patch should take care of the leak.
Signed-off-by: default avatarJesper Juhl <jj@chaosbits.net>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent ec2cf68e
...@@ -43,6 +43,7 @@ short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code, ...@@ -43,6 +43,7 @@ short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code,
struct pci_dev *dev = os_data; struct pci_dev *dev = os_data;
struct code_header header; struct code_header header;
char fw_name[20]; char fw_name[20];
short err_ret = HPI_ERROR_DSP_FILE_NOT_FOUND;
int err; int err;
sprintf(fw_name, "asihpi/dsp%04x.bin", adapter); sprintf(fw_name, "asihpi/dsp%04x.bin", adapter);
...@@ -85,8 +86,10 @@ short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code, ...@@ -85,8 +86,10 @@ short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code,
HPI_DEBUG_LOG(DEBUG, "dsp code %s opened\n", fw_name); HPI_DEBUG_LOG(DEBUG, "dsp code %s opened\n", fw_name);
dsp_code->pvt = kmalloc(sizeof(*dsp_code->pvt), GFP_KERNEL); dsp_code->pvt = kmalloc(sizeof(*dsp_code->pvt), GFP_KERNEL);
if (!dsp_code->pvt) if (!dsp_code->pvt) {
return HPI_ERROR_MEMORY_ALLOC; err_ret = HPI_ERROR_MEMORY_ALLOC;
goto error2;
}
dsp_code->pvt->dev = dev; dsp_code->pvt->dev = dev;
dsp_code->pvt->firmware = firmware; dsp_code->pvt->firmware = firmware;
...@@ -99,7 +102,7 @@ short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code, ...@@ -99,7 +102,7 @@ short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code,
release_firmware(firmware); release_firmware(firmware);
error1: error1:
dsp_code->block_length = 0; dsp_code->block_length = 0;
return HPI_ERROR_DSP_FILE_NOT_FOUND; return err_ret;
} }
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
......
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