Skip to contentSkip to conversation

sound: echoaudio: add a check for ioremap_nocache

PATCH Applied Kangjie Lu 2 participants 2 messages Mar 15, 2019 – Mar 16, 2019 Sound

lore
Share & tools
lore

Kangjie Lu

author
#0 lore raw

PATCH 1/1 sound: echoaudio: add a check for ioremap_nocache

In case ioremap_nocache fails, the fix releases chip and returns an error code upstream to avoid NULL pointer dereference.

---
 sound/pci/echoaudio/echoaudio.c | 5 +++++
 1 file changed, 5 insertions(+)
sound/pci/echoaudio/echoaudio.c +5 -0
index ea876b0b02b9..dc0084dc8550 100644
@@ -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)) {
Signature · 1 line
2.17.1
Applied
#1 lore raw
Quoted 5 lines · Kangjie Lu

In case ioremap_nocache fails, the fix releases chip and returns an error code upstream to avoid NULL pointer dereference.

Applied, thanks.

Takashi