linux-stable/sound
Ammar Faizi 67f7bd9ff9 ASoC: SOF: Intel: Fix NULL ptr dereference when ENOMEM
commit b7fb0ae090 upstream.

Do not call snd_dma_free_pages() when snd_dma_alloc_pages() returns
-ENOMEM because it leads to a NULL pointer dereference bug.

The dmesg says:

  [ T1387] sof-audio-pci-intel-tgl 0000:00:1f.3: error: memory alloc failed: -12
  [ T1387] BUG: kernel NULL pointer dereference, address: 0000000000000000
  [ T1387] #PF: supervisor read access in kernel mode
  [ T1387] #PF: error_code(0x0000) - not-present page
  [ T1387] PGD 0 P4D 0
  [ T1387] Oops: 0000 [#1] PREEMPT SMP NOPTI
  [ T1387] CPU: 6 PID: 1387 Comm: alsa-sink-HDA A Tainted: G        W         5.17.0-rc4-superb-owl-00055-g80d47f5de5e3
  [ T1387] Hardware name: HP HP Laptop 14s-dq2xxx/87FD, BIOS F.15 09/15/2021
  [ T1387] RIP: 0010:dma_free_noncontiguous+0x37/0x80
  [ T1387] Code: [... snip ...]
  [ T1387] RSP: 0000:ffffc90002b87770 EFLAGS: 00010246
  [ T1387] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
  [ T1387] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff888101db30d0
  [ T1387] RBP: 00000000fffffff4 R08: 0000000000000000 R09: 0000000000000000
  [ T1387] R10: 0000000000000000 R11: ffffc90002b874d0 R12: 0000000000000001
  [ T1387] R13: 0000000000058000 R14: ffff888105260c68 R15: ffff888105260828
  [ T1387] FS:  00007f42e2ffd640(0000) GS:ffff888466b80000(0000) knlGS:0000000000000000
  [ T1387] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  [ T1387] CR2: 0000000000000000 CR3: 000000014acf0003 CR4: 0000000000770ee0
  [ T1387] PKRU: 55555554
  [ T1387] Call Trace:
  [ T1387]  <TASK>
  [ T1387]  cl_stream_prepare+0x10a/0x120 [snd_sof_intel_hda_common 146addf995b9279ae7f509621078cccbe4f875e1]
  [... snip ...]
  [ T1387]  </TASK>

Cc: Daniel Baluta <daniel.baluta@nxp.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Cc: Keyon Jie <yang.jie@linux.intel.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Rander Wang <rander.wang@intel.com>
Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: sound-open-firmware@alsa-project.org
Cc: alsa-devel@alsa-project.org
Cc: linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org # v5.2+
Fixes: d16046ffa6 ("ASoC: SOF: Intel: Add Intel specific HDA firmware loader")
Link: https://lore.kernel.org/lkml/20220224145124.15985-1-ammarfaizi2@gnuweeb.org/ # v1
Link: https://lore.kernel.org/lkml/20220224180850.34592-1-ammarfaizi2@gnuweeb.org/ # v2
Link: https://lore.kernel.org/lkml/20220224182818.40301-1-ammarfaizi2@gnuweeb.org/ # v3
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Link: https://lore.kernel.org/r/20220224185836.44907-1-ammarfaizi2@gnuweeb.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-04-08 13:57:25 +02:00
..
ac97 bus: Make remove callback return void 2021-07-21 11:53:42 +02:00
aoa Kbuild updates for v5.15 2021-09-03 15:33:47 -07:00
arm ALSA: pxa2xx: Use managed PCM buffer allocation 2021-08-04 08:08:21 +02:00
atmel
core ALSA: pcm: Fix potential AB/BA lock with buffer_mutex and mmap_lock 2022-04-08 13:57:21 +02:00
drivers ALSA: virmidi: Remove duplicated code 2022-01-06 16:08:18 +01:00
firewire ALSA: fireworks: add support for Loud Onyx 1200f quirk 2021-11-11 14:02:02 +01:00
hda ALSA: Replace acpi_bus_get_device() 2022-02-01 08:08:08 +01:00
i2c ALSA: i2c: tea6330t: Remove redundant initialization of variable err 2021-06-12 09:32:14 +02:00
isa ALSA: cs4236: fix an incorrect NULL check on list iterator 2022-04-08 13:57:21 +02:00
mips ALSA: n64: check return value after calling platform_get_resource() 2021-06-12 09:31:13 +02:00
oss
parisc parisc architecture updates for kernel 5.15: 2021-09-02 13:16:00 -07:00
pci ALSA: hda/realtek: Fix audio regression on Mi Notebook Pro 2020 2022-04-08 13:57:22 +02:00
pcmcia ALSA: vx: Manage vx_core object with devres 2021-07-19 16:17:09 +02:00
ppc ALSA: ppc: beep: fix clang -Wimplicit-fallthrough 2021-12-07 15:36:56 +01:00
sh
soc ASoC: SOF: Intel: Fix NULL ptr dereference when ENOMEM 2022-04-08 13:57:25 +02:00
sparc ALSA: sparc: no need to initialise statics to 0 2021-12-12 10:01:04 +01:00
spi
synth ALSA: synth: missing check for possible NULL after the call to kstrdup 2021-11-09 07:18:50 +01:00
usb ALSA: usb-audio: Add mute TLV for playback volumes on RODE NT-USB 2022-03-28 10:03:19 +02:00
virtio virtio: wrap config->reset calls 2022-01-14 18:50:52 -05:00
x86 ALSA: intel_hdmi: Fix reference to PCM buffer address 2022-03-02 09:25:37 +01:00
xen xen: flag xen_snd_front to be not essential for system boot 2021-11-23 13:43:54 -06:00
Kconfig
Makefile
ac97_bus.c
last.c
sound_core.c