[PATCH] ALSA: korg1212: Fix crash in snd_korg1212_create()
Dan Carpenter
dan.carpenter at oracle.com
Wed Jul 21 16:01:22 CEST 2021
The "dsp_code" is not initialized until the next line so we can't
dereference it.
Fixes: b5cde369b618 ("ALSA: korg1212: Allocate resources with device-managed APIs")
Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>
---
sound/pci/korg1212/korg1212.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 7872abbd4587..3b2df5d06839 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -2256,17 +2256,17 @@ 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)
+ 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]);
--
2.20.1
More information about the Alsa-devel
mailing list