Skip to contentSkip to conversation

ALSA: control: Clear user-provided numid before adding a control

PATCH In review Sreeraj S Kurup 2 participants 3 messages Nov 2 – Nov 4 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: control: Clear user-provided numid before adding a control

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.

---
 sound/core/control.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/core/control.c +2 -1
index 535ceba294ac..42f16d2d0e79 100644
@@ -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;
Signature · 1 line
2.55.0
#1 lore raw
Quoted 10 lines · Sreeraj S Kurup

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.

Applied now. Thanks.

Takashi