Commit d364a600 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

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: b5cde369 ("ALSA: korg1212: Allocate resources with device-managed APIs")
Reported-by: default avatarNathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/s5heebsoc26.wl-tiwai@suse.de


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent f263a2c2
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -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]);