diff options
author | Takashi Iwai <tiwai@suse.de> | 2021-07-21 00:28:01 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2021-07-21 00:32:25 +0200 |
commit | d364a600d6ed9cd78744031a36627d21a6deaefd (patch) | |
tree | acb5bd7d78f43ea1cd436733d550d3f29689ce57 /sound/pci/korg1212 | |
parent | f263a2c2d6c7c44e9256e6a24c9fec668f22ff8b (diff) | |
download | lwn-d364a600d6ed9cd78744031a36627d21a6deaefd.tar.gz lwn-d364a600d6ed9cd78744031a36627d21a6deaefd.zip |
ALSA: korg1212: Fix wrongly shuffled firmware loader code
The recent change for the devres introduced the wrong code shuffling
in the korg1212 firmware loader function that may lead to a bad
pointer access. Restore the calls in the right order (and put back
the release_firmware() call in the error path, too).
Fixes: b5cde369b618 ("ALSA: korg1212: Allocate resources with device-managed APIs")
Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/s5heebsoc26.wl-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/korg1212')
-rw-r--r-- | sound/pci/korg1212/korg1212.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index 7872abbd4587..49ed2bfaf11f 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -2256,17 +2256,19 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci) korg1212->AdatTimeCodePhy = korg1212->sharedBufferPhy + offsetof(struct KorgSharedBuffer, AdatTimeCode); - korg1212->dma_dsp = snd_devm_alloc_pages(&pci->dev, SNDRV_DMA_TYPE_DEV, - dsp_code->size); - if (!korg1212->dma_dsp) - return -ENOMEM; - err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev); if (err < 0) { snd_printk(KERN_ERR "firmware not available\n"); return err; } + korg1212->dma_dsp = snd_devm_alloc_pages(&pci->dev, SNDRV_DMA_TYPE_DEV, + dsp_code->size); + if (!korg1212->dma_dsp) { + release_firmware(dsp_code); + return -ENOMEM; + } + K1212_DEBUG_PRINTK("K1212_DEBUG: DSP Code area = 0x%p (0x%08x) %d bytes [%s]\n", korg1212->dma_dsp->area, korg1212->dma_dsp->addr, dsp_code->size, stateName[korg1212->cardState]); |