Skip to contentSkip to conversation

ASoC: Intel: Replace deprecated strcpy() with strscpy()

PATCH In review Sachin Mokashi 3 participants 3 messages Jun 13, 2025 – Jun 16, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: Intel: Replace deprecated strcpy() with strscpy()

strcpy() is deprecated, use strscpy() instead.
As strcpy() performs no bounds checking on the destination buffer. This could result in buffer overflow. The safe replacement is strscpy().

---
 sound/soc/intel/boards/cht_bsw_rt5672.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/intel/boards/cht_bsw_rt5672.c +2 -1
index aaef212cf44e..54c1894ee96a 100644
@@ -14,6 +14,7 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/clk.h>
+#include <linux/string.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/soc.h>
@@ -458,7 +459,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
 	if (!drv)
 		return -ENOMEM;
 
-	strcpy(drv->codec_name, RT5672_I2C_DEFAULT);
+	strscpy(drv->codec_name, RT5672_I2C_DEFAULT, sizeof(drv->codec_name));
 
 	/* find index of codec dai */
 	for (i = 0; i < ARRAY_SIZE(cht_dailink); i++) {
Signature · 9 lines
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Sachin Mokashi

strcpy() is deprecated, use strscpy() instead.
As strcpy() performs no bounds checking on the destination buffer. This could result in buffer overflow. The safe replacement is strscpy().

LGTM

Quoted 26 lines
---
  sound/soc/intel/boards/cht_bsw_rt5672.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/intel/boards/cht_bsw_rt5672.c +2 -1
index aaef212cf44e..54c1894ee96a 100644
@@ -14,6 +14,7 @@
  #include <linux/platform_device.h>
  #include <linux/slab.h>
  #include <linux/clk.h>
+#include <linux/string.h>
  #include <sound/pcm.h>
  #include <sound/pcm_params.h>
  #include <sound/soc.h>
@@ -458,7 +459,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
  	if (!drv)
  		return -ENOMEM;
 
-	strcpy(drv->codec_name, RT5672_I2C_DEFAULT);
+	strscpy(drv->codec_name, RT5672_I2C_DEFAULT, sizeof(drv->codec_name));
 
  	/* find index of codec dai */
  	for (i = 0; i < ARRAY_SIZE(cht_dailink); i++) {
maintainer
#2 lore raw
In reply to Sachin Mokashi
Quoted 8 lines · Sachin Mokashi

strcpy() is deprecated, use strscpy() instead.
As strcpy() performs no bounds checking on the destination buffer. This could result in buffer overflow. The safe replacement is strscpy().

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: Intel: Replace deprecated strcpy() with strscpy()

      commit: 47972c1c3315672352f25c68f91dd88543541947

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark