All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: cht_bsw_rt5645: Fix writing to string literal
@ 2016-02-23  8:50 Carlo Caione
  2016-02-26  2:12 ` Mark Brown
  2016-02-26  2:46 ` Applied "ASoC: cht_bsw_rt5645: Fix writing to string literal" to the asoc tree Mark Brown
  0 siblings, 2 replies; 7+ messages in thread
From: Carlo Caione @ 2016-02-23  8:50 UTC (permalink / raw)
  To: lgirdwood, broonie, vinod.koul, yang.a.fang, linux, alsa-devel
  Cc: Carlo Caione

From: Carlo Caione <carlo@endlessm.com>

We cannot use strcpy() to write to a const char * location. This is
causing a 'BUG: unable to handle kernel paging request' error at boot
when using the cht-bsw-rt5645 driver.

With this patch we also fix a wrong indexing in the driver where the
codec_name of the wrong dai_link is being overwritten.

Signed-off-by: Carlo Caione <carlo@endlessm.com>
---
 sound/soc/intel/boards/cht_bsw_rt5645.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sound/soc/intel/boards/cht_bsw_rt5645.c b/sound/soc/intel/boards/cht_bsw_rt5645.c
index 2d3afdd..a7b96a9 100644
--- a/sound/soc/intel/boards/cht_bsw_rt5645.c
+++ b/sound/soc/intel/boards/cht_bsw_rt5645.c
@@ -367,8 +367,12 @@ 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);
+	for (i = 0; i < ARRAY_SIZE(cht_dailink); i++)
+		if (!strcmp(card->dai_link[i].codec_name, "i2c-10EC5645:00"))
+			card->dai_link[i].codec_name = kstrdup(codec_name, GFP_KERNEL);
+
 	snd_soc_card_set_drvdata(card, drv);
 	ret_val = devm_snd_soc_register_card(&pdev->dev, card);
 	if (ret_val) {
-- 
2.5.0

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

end of thread, other threads:[~2016-03-03 16:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-23  8:50 [PATCH v2] ASoC: cht_bsw_rt5645: Fix writing to string literal Carlo Caione
2016-02-26  2:12 ` Mark Brown
2016-03-03 11:32   ` Vinod Koul
2016-03-03 12:47     ` Carlo Caione
2016-03-03 16:11     ` Pierre-Louis Bossart
2016-03-03 16:16       ` Carlo Caione
2016-02-26  2:46 ` Applied "ASoC: cht_bsw_rt5645: Fix writing to string literal" to the asoc tree Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.