From 3b9f3b9431fe7adeca0bd3917f26a8877a1ee7e6 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 6 Sep 2024 09:58:47 +0200 Subject: [PATCH] Fixes: 5600b901 ("async: snd_async_del_handler - move clear signal using sigaction as last") A wrong list head is used to check if the given list with async handlers is empty. Correct this. Link: https://github.com/alsa-project/alsa-lib/issues/394 Signed-off-by: Jaroslav Kysela --- src/async.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/async.c b/src/async.c index a003e441..4117354a 100644 --- a/src/async.c +++ b/src/async.c @@ -153,9 +153,22 @@ int snd_async_del_handler(snd_async_handler_t *handler) int was_empty; assert(handler); if (handler->type != SND_ASYNC_HANDLER_GENERIC) { - if (!list_empty(&handler->hlist)) + struct list_head *alist; + switch (handler->type) { +#ifdef BUILD_PCM + case SND_ASYNC_HANDLER_PCM: + alist = &handler->u.pcm->async_handlers; + break; +#endif + case SND_ASYNC_HANDLER_CTL: + alist = &handler->u.ctl->async_handlers; + break; + default: + assert(0); + } + if (!list_empty(alist)) list_del(&handler->hlist); - if (!list_empty(&handler->hlist)) + if (!list_empty(alist)) goto _glist; switch (handler->type) { #ifdef BUILD_PCM