All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: control: Clear user-provided numid before adding a control
@ 2026-11-02 13:50 Sreeraj S Kurup
  2026-11-03 14:53 ` Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Sreeraj S Kurup @ 2026-11-02 13:50 UTC (permalink / raw)
  To: perex, tiwai
  Cc: cezary.rojewski, phucduc.bui, kees+treewide, cassiogabrielcontato,
	mstrozek, linux-sound, linux-kernel, 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.

Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-04 16:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-02 13:50 [PATCH] ALSA: control: Clear user-provided numid before adding a control Sreeraj S Kurup
2026-11-03 14:53 ` Takashi Iwai
2026-11-04 16:11   ` Sreeraj S Kurup

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.