]> git.alsa-project.org Git - alsa-lib.git/commitdiff
ucm: avoid relinking cached controls when adding an alias
authorReuben Grinberg <reuben.grinberg@aya.yale.edu>
Sun, 1 Nov 2026 18:49:36 +0000 (12:49 -0600)
committerJaroslav Kysela <perex@perex.cz>
Mon, 30 Nov 2026 14:10:55 +0000 (15:10 +0100)
uc_mgr_open_ctl() calls uc_mgr_ctl_add() with an existing entry when
another device name resolves to the same control card. Adding that
entry to ctl_list again corrupts the list and can double-free the
control handle during failed UCM import cleanup.

Only link entries allocated by this invocation. Existing entries keep
their original list membership while their device aliases are added.

Closes: https://github.com/alsa-project/alsa-lib/pull/539
Signed-off-by: Reuben Grinberg <reuben.grinberg@aya.yale.edu>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/ucm/utils.c

index d3e7c139b05f08ca679df39027e24136fa5486a1..b3691bea737b391e9e72e1a7f9b458ce53d8af3a 100644 (file)
@@ -255,7 +255,8 @@ static int uc_mgr_ctl_add(snd_use_case_mgr_t *uc_mgr,
                        goto __nomem;
        }
 
-       list_add_tail(&(*ctl_list)->list, &uc_mgr->ctl_list);
+       if (cl)
+               list_add_tail(&(*ctl_list)->list, &uc_mgr->ctl_list);
        return 0;
 
 __nomem: