mixer: alsa: Handle error from _alsa_card_create()

_alsa_card_create() can return NULL which can lead to a segmentation
fault inside ALSA when NULL is passed to snd_mixer_first_elem() in
_alsa_cards_refresh(). See the following crash dump excerpt:

Thread 1 (Thread 0x7fe64b227780 (LWP 3320) "enlightenment"):
#0  0x00007fe64c2fbd92 in __libc_pause () at ../sysdeps/unix/sysv/linux/pause.c:29
        sc_ret = -514
        sc_cancel_oldtype = 0
        sc_ret = <optimized out>
#1  <signal handler called>
No locals.
#2  list_empty (p=0x20) at /var/tmp/portage/media-libs/alsa-lib-1.2.9/work/alsa-lib-1.2.9/include/list.h:114
No locals.
#3  snd_mixer_first_elem (mixer=mixer@entry=0x0) at /var/tmp/portage/media-libs/alsa-lib-1.2.9/work/alsa-lib-1.2.9/src/mixer/mixer.c:803
No locals.
#4  0x00007fe63b2a376f in _alsa_cards_refresh () at ../enlightenment-0.25.4/src/modules/mixer/lib/backends/alsa/alsa.c:304
        buf = "hw:0\000le.emix.cfg\000C\236:\245U\000\000\035\221.;\346\177\000\000`>[;\245U\000\000\260g\302:\245U\000\000pL[;\245U\000\000ʁ-:\245U\000\000/home/andre/.e/e/config/standard/module.gadman.cfg", '\000' <repeats 710 times>...
        mixer = 0x0
        device_name = <optimized out>
        elem = <optimized out>
        source = 0x0
        sink = 0x0
        err = <optimized out>
        card_num = 0
        tmp_source = 0x0
        tmp_sink = 0x0
This commit is contained in:
Andre Schulz 2023-09-13 21:13:10 +02:00
parent 942a6bf135
commit 4bd15e3fec
1 changed files with 3 additions and 0 deletions

View File

@ -299,6 +299,9 @@ _alsa_cards_refresh(void)
//save the addr to see if there are missing devices in the cache list
mixer = _alsa_card_create(buf);
if (!mixer)
continue;
ctx->cards = eina_list_append(ctx->cards, mixer);
//get elements of the device
elem = snd_mixer_first_elem(mixer);