[PATCH] ALSA: control: Clear user-provided numid before adding a control

From: Sreeraj S Kurup

Date: Mon Nov 02 2026 - 08:59:17 EST


Clear the user-provided numid before checking for duplicate controls.

A non-existing numid can cause the duplicate control ID check to be
skipped, allowing a control with the same name and index to be added.

Since the kernel assigns the numid when adding a control,
ignore the value provided by userspace.

Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@xxxxxxxxx>
---
sound/core/control.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/core/control.c b/sound/core/control.c
index 535ceba294ac..42f16d2d0e79 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -1759,9 +1759,10 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file,
if (strnlen(info->id.name, sizeof(info->id.name)) >= sizeof(info->id.name))
return -EINVAL;

+ info->id.numid = 0;
+
/* Delete a control to replace them if needed. */
if (replace) {
- info->id.numid = 0;
err = snd_ctl_remove_user_ctl(file, &info->id);
if (err)
return err;
--
2.55.0