milos-linux/sound
Kean Ren e4c60a1d4b
ASoC: SDCA: fix NULL pointer dereference in sdca_dev_unregister_functions
sdca_dev_unregister_functions() iterates over all SDCA function
descriptors and calls sdca_dev_unregister() on each func_dev without
checking for NULL. When a function registration has failed partway
through, or the device cleanup races with probe deferral, func_dev
entries may be NULL, leading to a kernel oops:

  BUG: kernel NULL pointer dereference, address: 0000000000000040
  RIP: 0010:device_del+0x1e/0x3e0
  Call Trace:
   sdca_dev_unregister_functions+0x37/0x60 [snd_soc_sdca]
   release_nodes+0x35/0xb0
   devres_release_all+0x90/0x100
   device_unbind_cleanup+0xe/0x80
   device_release_driver_internal+0x1c1/0x200
   bus_remove_device+0xc6/0x130
   device_del+0x161/0x3e0
   device_unregister+0x17/0x60
   sdw_delete_slave+0xb6/0xd0 [soundwire_bus]
   sdw_bus_master_delete+0x1e/0x50 [soundwire_bus]
   ...
   sof_probe_work+0x19/0x30 [snd_sof]

This was observed on a Lenovo ThinkPad X1 Carbon G14 (Panther Lake)
with the SOF audio driver probe failing due to missing Panther Lake
firmware, causing the subsequent cleanup of SoundWire devices to
trigger the crash.

Fix this with three changes:

1) Add a NULL guard in sdca_dev_unregister() so that callers do not
   need to pre-validate the pointer (defense in depth).

2) In sdca_dev_unregister_functions(), skip NULL func_dev entries
   and clear func_dev to NULL after unregistration, making the
   function idempotent and safe against double-invocation.

3) In sdca_dev_register_functions(), roll back all previously
   registered functions when a later one fails, so the function
   array is never left in a partially-populated state.

Fixes: 4496d1c65b ("ASoC: SDCA: add function devices")
Signed-off-by: Kean Ren <rh_king@163.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://patch.msgid.link/20260611023757.1553960-1-rh_king@163.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-06-11 15:55:23 +01:00
..
ac97
aoa ALSA: aoa: onyx: Update IEC958 sample-rate status for PCM playback 2026-04-06 10:41:00 +02:00
arm ASoC: pxa2xx-ac97: fix error handling for reset GPIO descriptor 2026-04-13 18:00:34 +01:00
atmel
core ALSA: pcm: oss: Fix setup list UAF on proc write error 2026-05-25 09:23:10 +02:00
drivers ALSA: pcmtest: Return -EFAULT on pattern read copy failure 2026-05-04 13:26:23 +02:00
firewire ALSA: firewire-motu: Protect register DSP event queue positions 2026-05-25 09:19:44 +02:00
hda ALSA: hda/cs420x: Add CS4208 fixup for iMac16,1 2026-05-27 07:24:15 +02:00
i2c ALSA: i2c: ak4xxx-adda: seed AK5365 cache with reset defaults 2026-04-09 12:01:01 +02:00
isa ALSA: sscape: Add suspend and resume support 2026-04-12 10:00:34 +02:00
mips
oss
parisc
pci ALSA: asihpi: Fix potential OOB array access at reading cache 2026-05-16 15:41:58 +02:00
pcmcia
ppc
sh
soc ASoC: SDCA: fix NULL pointer dereference in sdca_dev_unregister_functions 2026-06-11 15:55:23 +01:00
sparc ALSA: sparc/dbri: add missing fallthrough 2026-05-06 10:09:17 +02:00
spi
synth
usb ALSA: usb-audio: Add iface reset and delay quirk for TAE1160 USB Audio 2026-05-27 07:24:15 +02:00
virtio ALSA: virtio: drop an extaneous kernel-doc comment 2026-04-17 09:47:54 +02:00
x86
xen
ac97_bus.c
Kconfig
last.c
Makefile
sound_core.c