Skip to contentSkip to conversation

ALSA: intel_hdmi: Fix off-by-one error in __hdmi_lpe_audio_probe()

PATCH Superseded Thorsten Blum 2 participants 3 messages Aug 5, 2025 – Aug 7, 2025

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: intel_hdmi: Fix off-by-one error in __hdmi_lpe_audio_probe()

In __hdmi_lpe_audio_probe(), strscpy() is incorrectly called with the length of the source string (excluding the NUL terminator) rather than the size of the destination buffer. This results in one character less being copied from 'card->shortname' to 'pcm->name'.

Since 'pcm->name' is a fixed-size buffer, we can safely omit the size argument and let strscpy() infer it using sizeof(). This ensures the card name is copied correctly.

Fixes 75b1a8f9d62e ("ALSA: Convert strlcpy to strscpy when return value is unused")
---
 sound/x86/intel_hdmi_audio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/x86/intel_hdmi_audio.c +1 -1
index cc54539c6030..fbef0cbe8f1a 100644
@@ -1765,7 +1765,7 @@ static int __hdmi_lpe_audio_probe(struct platform_device *pdev)
 		/* setup private data which can be retrieved when required */
 		pcm->private_data = ctx;
 		pcm->info_flags = 0;
-		strscpy(pcm->name, card->shortname, strlen(card->shortname));
+		strscpy(pcm->name, card->shortname);
 		/* setup the ops for playback */
 		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &had_pcm_ops);
 
Signature · 1 line
2.50.1
#1 lore raw

Hi Thorsten,

Thanks for the patch.

Quoted 21 lines · Thorsten Blum

In __hdmi_lpe_audio_probe(), strscpy() is incorrectly called with the length of the source string (excluding the NUL terminator) rather than the size of the destination buffer. This results in one character less being copied from 'card->shortname' to 'pcm->name'.

Since 'pcm->name' is a fixed-size buffer, we can safely omit the size argument and let strscpy() infer it using sizeof(). This ensures the card name is copied correctly.

Fixes 75b1a8f9d62e ("ALSA: Convert strlcpy to strscpy when return value is unused")
---
 sound/x86/intel_hdmi_audio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/x86/intel_hdmi_audio.c +0 -0
index cc54539c6030..fbef0cbe8f1a 100644

sound/x86/intel_hdmi_audio.c static int __hdmi_lpe_audio_probe(struct platform_device *pdev) · line 1768

Quoted 5 lines
sound/x86/intel_hdmi_audio.c +1 -1
@@ -1765,7 +1765,7 @@ static int __hdmi_lpe_audio_probe(struct platform_device *pdev)
 		/* setup private data which can be retrieved when required */
 		pcm->private_data = ctx;
 		pcm->info_flags = 0;
-		strscpy(pcm->name, card->shortname, strlen(card->shortname));
+		strscpy(pcm->name, card->shortname);

Could you use three arguments here for backporting -- the two-argument variant is a rather new addition and looks like 75b1a8f9d62e precedes it.

Quoted 3 lines
sound/x86/intel_hdmi_audio.c +0 -0
 		/* setup the ops for playback */
 		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &had_pcm_ops);
 
Signature · 3 lines
Regards,

Sakari Ailus
#2 lore raw

Hi Sakari,

Quoted 2 lines · Sakari Ailus

Could you use three arguments here for backporting -- the two-argument variant is a rather new addition and looks like 75b1a8f9d62e precedes it.

Thanks for the hint!

Best,
Thorsten