Linux kernel staging patches
 help / color / mirror / Atom feed
* [PATCH] staging: greybus: audio: fix snprintf truncation errors
@ 2026-06-05 19:28 Rhys Tumelty
  2026-06-06  7:08 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: Rhys Tumelty @ 2026-06-05 19:28 UTC (permalink / raw)
  To: gregkh
  Cc: Rhys Tumelty, Vaibhav Agarwal, Mark Greer, Johan Hovold,
	Alex Elder, greybus-dev, linux-staging, linux-kernel

change snprintf() to scnprintf() in both gbaudio_tplg_create_widget()
and gbaudio_tplg_process_kcontrols() to prevent potential string
truncation warnings when prefixing the device id to the control name.

Signed-off-by: Rhys Tumelty <rhys@tumelty.co.uk>
---
 drivers/staging/greybus/audio_topology.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c
index 76146f91c..b19febabb 100644
--- a/drivers/staging/greybus/audio_topology.c
+++ b/drivers/staging/greybus/audio_topology.c
@@ -1087,7 +1087,7 @@ static int gbaudio_tplg_create_widget(struct gbaudio_module_info *module,
 
 	/* Prefix dev_id to widget control_name */
 	strscpy(temp_name, w->name, sizeof(temp_name));
-	snprintf(w->name, sizeof(w->name), "GB %d %s", module->dev_id, temp_name);
+	scnprintf(w->name, sizeof(w->name), "GB %d %s", module->dev_id, temp_name);
 
 	switch (w->type) {
 	case snd_soc_dapm_spk:
@@ -1169,8 +1169,8 @@ static int gbaudio_tplg_process_kcontrols(struct gbaudio_module_info *module,
 		control->id = curr->id;
 		/* Prefix dev_id to widget_name */
 		strscpy(temp_name, curr->name, sizeof(temp_name));
-		snprintf(curr->name, sizeof(curr->name), "GB %d %s", module->dev_id,
-			 temp_name);
+		scnprintf(curr->name, sizeof(curr->name), "GB %d %s", module->dev_id,
+			  temp_name);
 		control->name = curr->name;
 		if (curr->info.type == GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED) {
 			struct gb_audio_enumerated *gbenum =
-- 
2.54.0


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

end of thread, other threads:[~2026-06-06  7:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-05 19:28 [PATCH] staging: greybus: audio: fix snprintf truncation errors Rhys Tumelty
2026-06-06  7:08 ` Dan Carpenter

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