1 From 7e325c1a4649dd8bc4d0bf94f9f408fe36180779 Mon Sep 17 00:00:00 2001
2 From: Kangjie Lu <kjlu@umn.edu>
3 Date: Thu, 14 Mar 2019 22:58:29 -0500
4 Subject: ALSA: echoaudio: add a check for ioremap_nocache
6 [ Upstream commit 6ade657d6125ec3ec07f95fa51e28138aef6208f ]
8 In case ioremap_nocache fails, the fix releases chip and returns
9 an error code upstream to avoid NULL pointer dereference.
11 Signed-off-by: Kangjie Lu <kjlu@umn.edu>
12 Signed-off-by: Takashi Iwai <tiwai@suse.de>
13 Signed-off-by: Sasha Levin <sashal@kernel.org>
15 sound/pci/echoaudio/echoaudio.c | 5 +++++
16 1 file changed, 5 insertions(+)
18 diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
19 index d68f99e076a8..e1f0bcd45c37 100644
20 --- a/sound/pci/echoaudio/echoaudio.c
21 +++ b/sound/pci/echoaudio/echoaudio.c
22 @@ -1953,6 +1953,11 @@ static int snd_echo_create(struct snd_card *card,
24 chip->dsp_registers = (volatile u32 __iomem *)
25 ioremap_nocache(chip->dsp_registers_phys, sz);
26 + if (!chip->dsp_registers) {
27 + dev_err(chip->card->dev, "ioremap failed\n");
28 + snd_echo_free(chip);
32 if (request_irq(pci->irq, snd_echo_interrupt, IRQF_SHARED,
33 KBUILD_MODNAME, chip)) {