mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ALSA: usb-audio: Use strscpy() in append_ctl_name()
@ 2026-10-21 10:58 Thorsten Blum
  2026-10-21 12:59 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-10-21 10:58 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, Rong Zhang, Arun Raghavan, Thorsten Blum
  Cc: Takashi Iwai, linux-sound, linux-kernel

To prepare for removing strlcat() from the kernel [1], use strscpy()
instead with the current name length as the append offset. Change
append_ctl_name() to return void since no caller uses its return value.

Use append_ctl_name() to append " Jack" in build_connector_control().

No functional change.

Link: https://github.com/KSPP/linux/issues/370 [1]
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
 sound/usb/mixer.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index ecaa8bc08d7c..0320a3e8af92 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -1720,9 +1720,11 @@ const struct snd_kcontrol_new *snd_usb_feature_unit_ctl = &usb_feature_unit_ctl;
 /*
  * build a feature control
  */
-static size_t append_ctl_name(struct snd_kcontrol *kctl, const char *str)
+static void append_ctl_name(struct snd_kcontrol *kctl, const char *str)
 {
-	return strlcat(kctl->id.name, str, sizeof(kctl->id.name));
+	size_t len = strlen(kctl->id.name);
+
+	strscpy(kctl->id.name + len, str, sizeof(kctl->id.name) - len);
 }
 
 /*
@@ -2090,7 +2092,7 @@ static void build_connector_control(struct usb_mixer_interface *mixer,
 	}
 
 	if (check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)))
-		strlcat(kctl->id.name, " Jack", sizeof(kctl->id.name));
+		append_ctl_name(kctl, " Jack");
 	else
 		get_connector_control_name(mixer, term, is_input, kctl->id.name,
 					   sizeof(kctl->id.name));

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

* Re: [PATCH] ALSA: usb-audio: Use strscpy() in append_ctl_name()
  2026-10-21 10:58 [PATCH] ALSA: usb-audio: Use strscpy() in append_ctl_name() Thorsten Blum
@ 2026-10-21 12:59 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-10-21 12:59 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Jaroslav Kysela, Takashi Iwai, Rong Zhang, Arun Raghavan,
	Takashi Iwai, linux-sound, linux-kernel

On Wed, 21 Oct 2026 12:58:26 +0200,
Thorsten Blum wrote:
> 
> To prepare for removing strlcat() from the kernel [1], use strscpy()
> instead with the current name length as the append offset. Change
> append_ctl_name() to return void since no caller uses its return value.
> 
> Use append_ctl_name() to append " Jack" in build_connector_control().
> 
> No functional change.
> 
> Link: https://github.com/KSPP/linux/issues/370 [1]
> Signed-off-by: Thorsten Blum <blum@kernel.org>

Applied now.  Thanks.


Takashi

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

end of thread, other threads:[~2026-10-21 12:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-21 10:58 [PATCH] ALSA: usb-audio: Use strscpy() in append_ctl_name() Thorsten Blum
2026-10-21 12:59 ` Takashi Iwai

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

all inboxes | Powered by JetHome®