Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] ALSA: control: Trim whitespace from sysfs input
@ 2026-11-06 16:55 Sreeraj S Kurup
  2026-11-06 17:02 ` sashiko-bot
  2026-11-06 17:26 ` [PATCH v2] " Sreeraj S Kurup
  0 siblings, 2 replies; 6+ messages in thread
From: Sreeraj S Kurup @ 2026-11-06 16:55 UTC (permalink / raw)
  To: perex, tiwai, tiwai; +Cc: linux-kernel, linux-sound, Sreeraj S Kurup

The attach and detach sysfs interfaces receive input from
userspace.

When userspace writes a value using echo, the input normally
ends with a newline character.

The parser does not remove this newline in all input formats.
For example, a bare numeric ID can be treated as a control name,
and an unquoted name= field can include the newline.

Trim leading and trailing whitespace before parsing the input.

This keeps spaces inside mixer control names unchanged.

Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
 sound/core/control_led.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sound/core/control_led.c b/sound/core/control_led.c
index 501387287ae6..a640e7835ce2 100644
--- a/sound/core/control_led.c
+++ b/sound/core/control_led.c
@@ -518,6 +518,11 @@ static ssize_t set_led_id(struct snd_ctl_led_card *led_card, const char *buf, si
 
 	if (strscpy(buf2, buf, sizeof(buf2)) < 0)
 		return -E2BIG;
+
+	s = strim(buf2);
+	if (s != buf2)
+		memmove(buf2, s, strlen(s) + 1);
+
 	memset(&id, 0, sizeof(id));
 	id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
 	s = buf2;
-- 
2.55.0


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

* Re: [PATCH] ALSA: control: Trim whitespace from sysfs input
  2026-11-06 16:55 [PATCH] ALSA: control: Trim whitespace from sysfs input Sreeraj S Kurup
@ 2026-11-06 17:02 ` sashiko-bot
  2026-11-06 17:26 ` [PATCH v2] " Sreeraj S Kurup
  1 sibling, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-11-06 17:02 UTC (permalink / raw)
  To: Sreeraj S Kurup; +Cc: linux-sound

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] ALSA: control: missing Fixes trailer for set_led_id() whitespace
  fix
--

commit fba9994b6098b77ca57c53a57ff6876210ceae6a
Author: Sreeraj S Kurup <sreekuttan2156239@gmail.com>

> ALSA: control: Trim whitespace from sysfs input
>
> The attach and detach sysfs interfaces receive input from
> userspace.
>
> When userspace writes a value using echo, the input normally
> ends with a newline character.
>
> The parser does not remove this newline in all input formats.
> For example, a bare numeric ID can be treated as a control name,
> and an unquoted name= field can include the newline.
>
> Trim leading and trailing whitespace before parsing the input.
>
> This keeps spaces inside mixer control names unchanged.
>
> Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>

[Severity: Low]
Since this fixes newline handling in set_led_id(), should it include:

  Fixes: a135dfb5de15 ("ALSA: led control - add sysfs kcontrol LED marking layer")

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261106165531.4074-1-sreekuttan2156239@gmail.com?part=1

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

* [PATCH v2] ALSA: control: Trim whitespace from sysfs input
  2026-11-06 16:55 [PATCH] ALSA: control: Trim whitespace from sysfs input Sreeraj S Kurup
  2026-11-06 17:02 ` sashiko-bot
@ 2026-11-06 17:26 ` Sreeraj S Kurup
  2026-11-07  9:03   ` Takashi Iwai
  1 sibling, 1 reply; 6+ messages in thread
From: Sreeraj S Kurup @ 2026-11-06 17:26 UTC (permalink / raw)
  To: sreekuttan2156239; +Cc: linux-kernel, linux-sound, perex, tiwai, tiwai

The attach and detach sysfs interfaces receive input from
userspace.

When userspace writes a value using echo, the input normally
ends with a newline character.

The parser does not remove this newline in all input formats.
For example, a bare numeric ID can be treated as a control name,
and an unquoted name= field can include the newline.

Trim leading and trailing whitespace before parsing the input.

This keeps spaces inside mixer control names unchanged.

Fixes: a135dfb5de15 ("ALSA: led control - add sysfs kcontrol LED marking layer")
Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
v2:
 - Add the Fixes trailer.

 sound/core/control_led.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sound/core/control_led.c b/sound/core/control_led.c
index 501387287ae6..a640e7835ce2 100644
--- a/sound/core/control_led.c
+++ b/sound/core/control_led.c
@@ -518,6 +518,11 @@ static ssize_t set_led_id(struct snd_ctl_led_card *led_card, const char *buf, si
 
 	if (strscpy(buf2, buf, sizeof(buf2)) < 0)
 		return -E2BIG;
+
+	s = strim(buf2);
+	if (s != buf2)
+		memmove(buf2, s, strlen(s) + 1);
+
 	memset(&id, 0, sizeof(id));
 	id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
 	s = buf2;
-- 
2.55.0


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

* Re: [PATCH v2] ALSA: control: Trim whitespace from sysfs input
  2026-11-06 17:26 ` [PATCH v2] " Sreeraj S Kurup
@ 2026-11-07  9:03   ` Takashi Iwai
  2026-11-07 11:49     ` Sreeraj S Kurup
  2026-11-07 11:51     ` Sreeraj S Kurup
  0 siblings, 2 replies; 6+ messages in thread
From: Takashi Iwai @ 2026-11-07  9:03 UTC (permalink / raw)
  To: Sreeraj S Kurup; +Cc: linux-kernel, linux-sound, perex, tiwai, tiwai

On Fri, 06 Nov 2026 18:26:25 +0100,
Sreeraj S Kurup wrote:
> 
> The attach and detach sysfs interfaces receive input from
> userspace.
> 
> When userspace writes a value using echo, the input normally
> ends with a newline character.
> 
> The parser does not remove this newline in all input formats.
> For example, a bare numeric ID can be treated as a control name,
> and an unquoted name= field can include the newline.
> 
> Trim leading and trailing whitespace before parsing the input.
> 
> This keeps spaces inside mixer control names unchanged.
> 
> Fixes: a135dfb5de15 ("ALSA: led control - add sysfs kcontrol LED marking layer")
> Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>

Applied to for-next branch.  Thanks.


Takashi

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

* Re: [PATCH v2] ALSA: control: Trim whitespace from sysfs input
  2026-11-07  9:03   ` Takashi Iwai
@ 2026-11-07 11:49     ` Sreeraj S Kurup
  2026-11-07 11:51     ` Sreeraj S Kurup
  1 sibling, 0 replies; 6+ messages in thread
From: Sreeraj S Kurup @ 2026-11-07 11:49 UTC (permalink / raw)
  To: tiwai; +Cc: linux-kernel, linux-sound, perex, sreekuttan2156239, tiwai

Thanks for applying the patch!

Best regards,
Sreeraj

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

* Re: [PATCH v2] ALSA: control: Trim whitespace from sysfs input
  2026-11-07  9:03   ` Takashi Iwai
  2026-11-07 11:49     ` Sreeraj S Kurup
@ 2026-11-07 11:51     ` Sreeraj S Kurup
  1 sibling, 0 replies; 6+ messages in thread
From: Sreeraj S Kurup @ 2026-11-07 11:51 UTC (permalink / raw)
  To: tiwai; +Cc: linux-kernel, linux-sound, perex, sreekuttan2156239, tiwai

Hi,

Thanks for applying the patch!

Best regards,
Sreeraj

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

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

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-06 16:55 [PATCH] ALSA: control: Trim whitespace from sysfs input Sreeraj S Kurup
2026-11-06 17:02 ` sashiko-bot
2026-11-06 17:26 ` [PATCH v2] " Sreeraj S Kurup
2026-11-07  9:03   ` Takashi Iwai
2026-11-07 11:49     ` Sreeraj S Kurup
2026-11-07 11:51     ` Sreeraj S Kurup

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox