diff options
author | Takashi Iwai <tiwai@suse.de> | 2013-02-10 11:58:40 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-02-10 11:58:40 +0100 |
commit | b3667bd7579e6d4dfe709315f13cff9bc9ee9053 (patch) | |
tree | 6edfef15c2a1598de92c6fff7f17700ffb4ec53c /sound/pci/hda/hda_intel.c | |
parent | 6d67530e2c73e375b9204eba10ee2d589ba353ae (diff) |
ALSA: hda - Fix memory leak and error handling in CA0132 DSP loader
This patch fixes a few obvious bugs in DSP loader stuff:
- Fix possible memory leaks in the error path
- Avoid double-free calls in dma_reset()
- Properly set/unset WC bits for DMA buffers
- Add missing error status checks
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_intel.c')
-rw-r--r-- | sound/pci/hda/hda_intel.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 1f8ce216edb..bb9179e4679 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -2628,8 +2628,9 @@ static int azx_load_dsp_prepare(struct hda_bus *bus, unsigned int format, snd_dma_pci_data(chip->pci), byte_size, bufp); if (err < 0) - goto error; + goto unlock; + mark_pages_wc(chip, bufp, true); azx_dev = azx_get_dsp_loader_dev(chip); azx_dev->bufsize = byte_size; azx_dev->period_bytes = byte_size; @@ -2651,6 +2652,9 @@ static int azx_load_dsp_prepare(struct hda_bus *bus, unsigned int format, return azx_dev->stream_tag; error: + mark_pages_wc(chip, bufp, false); + snd_dma_free_pages(bufp); +unlock: snd_hda_unlock_devices(bus); return err; } @@ -2673,6 +2677,9 @@ static void azx_load_dsp_cleanup(struct hda_bus *bus, struct azx *chip = bus->private_data; struct azx_dev *azx_dev = azx_get_dsp_loader_dev(chip); + if (!dmab->area) + return; + /* reset BDL address */ azx_sd_writel(azx_dev, SD_BDLPL, 0); azx_sd_writel(azx_dev, SD_BDLPU, 0); @@ -2681,7 +2688,9 @@ static void azx_load_dsp_cleanup(struct hda_bus *bus, azx_dev->period_bytes = 0; azx_dev->format_val = 0; + mark_pages_wc(chip, dmab, false); snd_dma_free_pages(dmab); + dmab->area = NULL; snd_hda_unlock_devices(bus); } |