diff options
author | Jesper Juhl <jj@chaosbits.net> | 2011-07-31 17:16:43 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-08-01 04:57:06 -0400 |
commit | dc889f18646325d07eb24ef634f082d60b0beebb (patch) | |
tree | b8e5c38980bf8bd88219da923800dfceae6156ef /sound | |
parent | ec2cf68e024b4f66df11683147d63e07db6ee875 (diff) |
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.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sound/pci/asihpi/hpidspcd.c b/sound/pci/asihpi/hpidspcd.c index 3a7afa31c1d8..71d32c868c92 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, | |||
43 | struct pci_dev *dev = os_data; | 43 | struct pci_dev *dev = os_data; |
44 | struct code_header header; | 44 | struct code_header header; |
45 | char fw_name[20]; | 45 | char fw_name[20]; |
46 | short err_ret = HPI_ERROR_DSP_FILE_NOT_FOUND; | ||
46 | int err; | 47 | int err; |
47 | 48 | ||
48 | sprintf(fw_name, "asihpi/dsp%04x.bin", adapter); | 49 | 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 | 86 | ||
86 | HPI_DEBUG_LOG(DEBUG, "dsp code %s opened\n", fw_name); | 87 | HPI_DEBUG_LOG(DEBUG, "dsp code %s opened\n", fw_name); |
87 | dsp_code->pvt = kmalloc(sizeof(*dsp_code->pvt), GFP_KERNEL); | 88 | dsp_code->pvt = kmalloc(sizeof(*dsp_code->pvt), GFP_KERNEL); |
88 | if (!dsp_code->pvt) | 89 | if (!dsp_code->pvt) { |
89 | return HPI_ERROR_MEMORY_ALLOC; | 90 | err_ret = HPI_ERROR_MEMORY_ALLOC; |
91 | goto error2; | ||
92 | } | ||
90 | 93 | ||
91 | dsp_code->pvt->dev = dev; | 94 | dsp_code->pvt->dev = dev; |
92 | dsp_code->pvt->firmware = firmware; | 95 | dsp_code->pvt->firmware = firmware; |
@@ -99,7 +102,7 @@ error2: | |||
99 | release_firmware(firmware); | 102 | release_firmware(firmware); |
100 | error1: | 103 | error1: |
101 | dsp_code->block_length = 0; | 104 | dsp_code->block_length = 0; |
102 | return HPI_ERROR_DSP_FILE_NOT_FOUND; | 105 | return err_ret; |
103 | } | 106 | } |
104 | 107 | ||
105 | /*-------------------------------------------------------------------*/ | 108 | /*-------------------------------------------------------------------*/ |