[PATCH] ALSA: usb-audio: Use strscpy() in append_ctl_name()

From: Thorsten Blum

Date: Wed Oct 21 2026 - 07:06:50 EST


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@xxxxxxxxxx>
---
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));