ASoC: cht_bsw_rt5645: Fix writing to string literal
Subsystems (3)
PATCH v2 1/1 ASoC: cht_bsw_rt5645: Fix writing to string literal
From: Carlo Caione <[email protected]>
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.
--- sound/soc/intel/boards/cht_bsw_rt5645.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/soc/intel/boards/cht_bsw_rt5645.c +5 -1
@@ -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) {
Signature · 1 line
2.5.0
Mark Brown
maintainerQuoted 8 lines · Carlo Caione
From: Carlo Caione <[email protected]>
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_nameof the wrongdai_linkis being overwritten.
So how was the original code tested then...?
Quoted 11 lines · Mark Brown
Quoted 8 lines · Carlo Caione
From: Carlo Caione <[email protected]>
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_nameof the wrongdai_linkis being overwritten.So how was the original code tested then...?
I know systems using this are shipping so surprised to see this.
Carlo cna you please tell me the configuration where it is seen.
Also would be worth mentioning here that Pierre is working on a super fix for this which involves removing this code and getting the right IDs from BIOS, so we wont need this code.
Thanks
Signature · 1 line
~Vinod
Quoted 8 lines · Vinod Koul
Quoted 7 lines · Mark Brown
Quoted 6 lines · Carlo Caione
From: Carlo Caione <[email protected]>
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.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
With this patch we also fix a wrong indexing in the driver where the
codec_nameof the wrongdai_linkis being overwritten.So how was the original code tested then...?
I know systems using this are shipping so surprised to see this.
Carlo cna you please tell me the configuration where it is seen.
Hi Vinod,
I'm working on the ECS EF20EA cherry-trail laptop. This is the used configuration:
https://gist.github.com/carlocaione/925540bc7b04eff01aa8
Cheers,
Signature · 1 line
Carlo Caione | +39.340.80.30.096 | Endless
Quoted 13 lines · Vinod Koul
Quoted 11 lines · Mark Brown
Quoted 8 lines · Carlo Caione
From: Carlo Caione <[email protected]>
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_nameof the wrongdai_linkis being overwritten.So how was the original code tested then...?
Quoted 7 lines
I know systems using this are shipping so surprised to see this.
Carlo cna you please tell me the configuration where it is seen.
Also would be worth mentioning here that Pierre is working on a super fix for this which involves removing this code and getting the right IDs from BIOS, so we wont need this code.
I am actually using the same code to find out which DAI fields need to be replaced instead of hard-codec indices so the loop part is a good thing.
There is still a need to copy a string, be it a constant to generated from the HID, into the codec_name field. I am not clear why strcpy() works on all my systems and why kstrdup() is required. Is the kernel issue really due to this string handling or to the bad index?
Quoted 28 lines · Pierre-Louis Bossart
Quoted 18 lines · Vinod Koul
Quoted 9 lines · Mark Brown
Quoted 7 lines · Carlo Caione
From: Carlo Caione <[email protected]>
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.Quoted 5 lines
Quoted 2 lines
With this patch we also fix a wrong indexing in the driver where the
codec_nameof the wrongdai_linkis being overwritten.So how was the original code tested then...?
Quoted 7 lines
I know systems using this are shipping so surprised to see this.
Carlo cna you please tell me the configuration where it is seen.
Also would be worth mentioning here that Pierre is working on a super fix for this which involves removing this code and getting the right IDs from BIOS, so we wont need this code.
Quoted 6 lines
I am actually using the same code to find out which DAI fields need to be replaced instead of hard-codec indices so the loop part is a good thing. There is still a need to copy a string, be it a constant to generated from the HID, into the
codec_namefield. I am not clear whystrcpy()works on all my systems and whykstrdup()is required. Is the kernel issue really due to this string handling or to the bad index?
In my tests using kstrdup() fixed the BUG issue and the bad indexing fix was required to have the driver working correctly.
Signature · 1 line
Carlo Caione
Mark Brown
maintainerApplied "ASoC: cht_bsw_rt5645: Fix writing to string literal" to the asoc tree
In reply to Carlo CaioneThe patch
ASoC: cht_bsw_rt5645: Fix writing to string literal
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
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
Quoted 1 line
From
c8560b7c917f8738f5d80dd516930edc1d05e4e4Mon Sep 17 00:00:00 2001
From: Carlo Caione <[email protected]>
Date: Tue, 23 Feb 2016 09:50:20 +0100
Subject: [PATCH] ASoC: cht_bsw_rt5645: Fix writing to string literal
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.
--- sound/soc/intel/boards/cht_bsw_rt5645.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/soc/intel/boards/cht_bsw_rt5645.c +5 -1
@@ -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) {
Signature · 1 line
2.7.0