summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorJesper Juhl <jj@chaosbits.net>2011-07-31 23:16:43 +0200
committerTakashi Iwai <tiwai@suse.de>2011-08-01 10:57:06 +0200
commitdc889f18646325d07eb24ef634f082d60b0beebb (patch)
treeb8e5c38980bf8bd88219da923800dfceae6156ef /sound
parentec2cf68e024b4f66df11683147d63e07db6ee875 (diff)
downloadop-kernel-dev-dc889f18646325d07eb24ef634f082d60b0beebb.zip
op-kernel-dev-dc889f18646325d07eb24ef634f082d60b0beebb.tar.gz
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: Jesper Juhl <jj@chaosbits.net> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/asihpi/hpidspcd.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sound/pci/asihpi/hpidspcd.c b/sound/pci/asihpi/hpidspcd.c
index 3a7afa3..71d32c8 100644
--- a/sound/pci/asihpi/hpidspcd.c
+++ b/sound/pci/asihpi/hpidspcd.c
@@ -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 code_header header;
char fw_name[20];
+ short err_ret = HPI_ERROR_DSP_FILE_NOT_FOUND;
int err;
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,
HPI_DEBUG_LOG(DEBUG, "dsp code %s opened\n", fw_name);
dsp_code->pvt = kmalloc(sizeof(*dsp_code->pvt), GFP_KERNEL);
- if (!dsp_code->pvt)
- return HPI_ERROR_MEMORY_ALLOC;
+ if (!dsp_code->pvt) {
+ err_ret = HPI_ERROR_MEMORY_ALLOC;
+ goto error2;
+ }
dsp_code->pvt->dev = dev;
dsp_code->pvt->firmware = firmware;
@@ -99,7 +102,7 @@ error2:
release_firmware(firmware);
error1:
dsp_code->block_length = 0;
- return HPI_ERROR_DSP_FILE_NOT_FOUND;
+ return err_ret;
}
/*-------------------------------------------------------------------*/
OpenPOWER on IntegriCloud