Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH] ALSA: intel_hdmi: Fix off-by-one error in __hdmi_lpe_audio_probe()
@ 2025-08-05 19:08 Thorsten Blum
  2025-08-05 23:17 ` Sakari Ailus
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Blum @ 2025-08-05 19:08 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, Thorsten Blum, Sakari Ailus,
	Mark Brown, Joe Perches
  Cc: stable, Takashi Iwai, linux-sound, linux-kernel

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.

Cc: stable@vger.kernel.org
Fixes: 75b1a8f9d62e ("ALSA: Convert strlcpy to strscpy when return value is unused")
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 sound/x86/intel_hdmi_audio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index cc54539c6030..fbef0cbe8f1a 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -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);
 
-- 
2.50.1


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

* Re: [PATCH] ALSA: intel_hdmi: Fix off-by-one error in __hdmi_lpe_audio_probe()
  2025-08-05 19:08 [PATCH] ALSA: intel_hdmi: Fix off-by-one error in __hdmi_lpe_audio_probe() Thorsten Blum
@ 2025-08-05 23:17 ` Sakari Ailus
  2025-08-07  3:13   ` Thorsten Blum
  0 siblings, 1 reply; 3+ messages in thread
From: Sakari Ailus @ 2025-08-05 23:17 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Jaroslav Kysela, Takashi Iwai, Mark Brown, Joe Perches, stable,
	Takashi Iwai, linux-sound, linux-kernel

Hi Thorsten,

Thanks for the patch. 

On Tue, Aug 05, 2025 at 09:08:06PM +0200, Thorsten Blum wrote:
> 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.
> 
> Cc: stable@vger.kernel.org
> Fixes: 75b1a8f9d62e ("ALSA: Convert strlcpy to strscpy when return value is unused")
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  sound/x86/intel_hdmi_audio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
> index cc54539c6030..fbef0cbe8f1a 100644
> --- a/sound/x86/intel_hdmi_audio.c
> +++ b/sound/x86/intel_hdmi_audio.c
> @@ -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.

>  		/* setup the ops for playback */
>  		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &had_pcm_ops);
>  

-- 
Regards,

Sakari Ailus

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

* Re: [PATCH] ALSA: intel_hdmi: Fix off-by-one error in __hdmi_lpe_audio_probe()
  2025-08-05 23:17 ` Sakari Ailus
@ 2025-08-07  3:13   ` Thorsten Blum
  0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Blum @ 2025-08-07  3:13 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Jaroslav Kysela, Takashi Iwai, Mark Brown, Joe Perches, stable,
	Takashi Iwai, linux-sound, linux-kernel

Hi Sakari,

On 6. Aug 2025, at 01:17, Sakari Ailus wrote:
> 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


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

end of thread, other threads:[~2025-08-07  3:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-05 19:08 [PATCH] ALSA: intel_hdmi: Fix off-by-one error in __hdmi_lpe_audio_probe() Thorsten Blum
2025-08-05 23:17 ` Sakari Ailus
2025-08-07  3:13   ` Thorsten Blum

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