ALSA: echoaudio: add a check for ioremap_nocache
authorKangjie Lu <kjlu@umn.edu>
Fri, 15 Mar 2019 03:58:29 +0000 (22:58 -0500)
committerTakashi Iwai <tiwai@suse.de>
Sat, 16 Mar 2019 09:29:02 +0000 (10:29 +0100)
In case ioremap_nocache fails, the fix releases chip and returns
an error code upstream to avoid NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/echoaudio/echoaudio.c

index ea876b0b02b9f0d8400a7ee08291ff283999dbc6..dc0084dc8550daae4412f75e7bfc487c69c98beb 100644 (file)
@@ -1952,6 +1952,11 @@ static int snd_echo_create(struct snd_card *card,
        }
        chip->dsp_registers = (volatile u32 __iomem *)
                ioremap_nocache(chip->dsp_registers_phys, sz);
+       if (!chip->dsp_registers) {
+               dev_err(chip->card->dev, "ioremap failed\n");
+               snd_echo_free(chip);
+               return -ENOMEM;
+       }
 
        if (request_irq(pci->irq, snd_echo_interrupt, IRQF_SHARED,
                        KBUILD_MODNAME, chip)) {