[alsa-devel] [PATCH] cht_bsw_rt5645: Fix Kernel crash with strcpy

Jenny TC jenny.tc at intel.com
Tue Jul 14 18:36:51 CEST 2015


Kernel crash is observed when strcpy is used with  const char*.
The crash is reported only if driver is loaded as a module or the probe
is called in the late stage of  Kernel boot (EPROBE_DEFER). This is because
Kernel enables read only protection near the end. Issue is addressed
by replacing the strcpy with pointer assignment

Signed-off-by: Jenny TC <jenny.tc at intel.com>
---
 sound/soc/intel/boards/cht_bsw_rt5645.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/intel/boards/cht_bsw_rt5645.c b/sound/soc/intel/boards/cht_bsw_rt5645.c
index bdcaf46..3665d6c 100644
--- a/sound/soc/intel/boards/cht_bsw_rt5645.c
+++ b/sound/soc/intel/boards/cht_bsw_rt5645.c
@@ -367,7 +367,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
 	card->dev = &pdev->dev;
 	sprintf(codec_name, "i2c-%s:00", drv->acpi_card->codec_id);
 	/* set correct codec name */
-	strcpy((char *)card->dai_link[2].codec_name, codec_name);
+	card->dai_link[2].codec_name = codec_name;
 	snd_soc_card_set_drvdata(card, drv);
 	ret_val = devm_snd_soc_register_card(&pdev->dev, card);
 	if (ret_val) {
-- 
1.7.9.5



More information about the Alsa-devel mailing list