From: Jaroslav Kysela Date: Mon, 23 Nov 2026 14:43:14 +0000 (+0100) Subject: ucm: drop self-references in SupportedDevice/ConflictingDevice lists X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=3a0a1b535c5a609dc20eb054db4ff7f0e35cd3f9;p=alsa-lib.git ucm: drop self-references in SupportedDevice/ConflictingDevice lists When a device lists its own name in its SupportedDevice or ConflictingDevice list, the relationship is ambiguous: a device cannot meaningfully support or conflict with itself. Drop such self-references in verb_resolve_optional_devices(), after optional references have been resolved and before the bidirectional relationships are built, so they do not propagate to other devices. Signed-off-by: Jaroslav Kysela --- diff --git a/src/ucm/parser.c b/src/ucm/parser.c index 68498617..95520f30 100644 --- a/src/ucm/parser.c +++ b/src/ucm/parser.c @@ -2124,10 +2124,27 @@ static int verb_resolve_optional_devices(snd_use_case_mgr_t *uc_mgr, return 0; list_for_each(pos, &verb->device_list) { + struct list_head *pos2, *npos2; + struct dev_list_node *dlist; + device = list_entry(pos, struct use_case_device, list); err = dev_list_resolve_optional(verb, &device->dev_list); if (err < 0) return err; + /* + * Drop references where a device lists its own name in its + * supported or conflicting list. A device cannot meaningfully + * support or conflict with itself and such a relationship is + * ambiguous, so the self-reference is silently removed. + */ + list_for_each_safe(pos2, npos2, &device->dev_list.list) { + dlist = list_entry(pos2, struct dev_list_node, list); + if (strcmp(dlist->name, device->name) != 0) + continue; + list_del(&dlist->list); + free(dlist->name); + free(dlist); + } } list_for_each(pos, &verb->modifier_list) { modifier = list_entry(pos, struct use_case_modifier, list);