Uh oh!
There was an error while loading. Please reload this page.
ASoC: Intel: Boards: cml_rt1011_rt5682: use statically define codec c… - #2173
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
352da05 to
4b3ec69Compare
lyakh
left a comment
There was a problem hiding this comment.
"When the machine driver probe is deferred, the memory allocated during probe seems to be corrupted" - I think it would be nice to actually understand what's going on there. Do you mean that happens when the driver probing returns -EPROBE_DEFER? AFAICT from the PoV of the driver probing it should be treated just like a normal probing failure, e.g. all the devm_* resources should be freed. Is this what you're referring to?
bardliao
commented
Jun 8, 2020
@lyakh The PR is for #2168. It do fix the issue, but it may not point to the right reason. See #2168 (comment). Alternative solution is #2174 However, I like this PR anyway. Statically define is always more readable. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
ranj063
commented
Jun 8, 2020
@bardliao I think this solution is bit more straightforward as well and the risks of use-after-free are lower with this one and the code is a lot simpler. So if you agree maybe we can go with this one once @fredoh9 fixes the comments on the commit message and the separate patch to change the dev_info to dev_dbg |
plbossart
commented
Jun 8, 2020
we also want the last patch from @bardliao to walk through the dalinks |
fredoh9
commented
Jun 8, 2020
I addressed @plbossart comments and cherry-pick @bardliao 2nd patch also. I need to more testing with it now. Will update my branch in shortly. |
4b3ec69 to
c5ea25bCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
… quirk Change dev_info to dev_dbg to reduce noise during multiple deferred probes. Signed-off-by: Fred Oh <fred.oh@linux.intel.com>
c5ea25b to
e33af32CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
e33af32 to
2d85740Compare| cml_rt1011_rt5682_dailink[i].codecs = ssp1_codec_4spk; | ||
| cml_rt1011_rt5682_dailink[i].num_codecs = | ||
| ARRAY_SIZE(ssp1_codec_4spk); | ||
| CML_RT1011_CODEC_DAI)) { |
Uh oh!
There was an error while loading. Please reload this page.
fredoh9
commented
Jun 8, 2020
From device test, one error is reported in CML_RVP. I will look into it and address @plbossart comments. |
2d85740 to
025922dCompareAddressed @plbossart 's two comments. For KMOD test, I tested with both CML Helios and CML_RVP_HDA. I worked fine for 25 iterations. And I don't think this change to do with |
plbossart
commented
Jun 8, 2020
the alignment is still off diff --git a/sound/soc/intel/boards/cml_rt1011_rt5682.c b/sound/soc/intel/boards/cml_rt1011_rt5682.c
index bb9862ff23ae..d56c708a332b 100644
--- a/sound/soc/intel/boards/cml_rt1011_rt5682.c+++ b/sound/soc/intel/boards/cml_rt1011_rt5682.c@@ -548,7 +548,7 @@ static int snd_cml_rt1011_probe(struct platform_device *pdev)
SOF_RT1011_SPEAKER_TR)) {
for_each_card_prelinks(&snd_soc_card_cml, i, dai_link) {
if (!strcmp(cml_rt1011_rt5682_dailink[i].codecs->dai_name,
- CML_RT1011_CODEC_DAI)) {+ CML_RT1011_CODEC_DAI)) {
dai_link->codecs = ssp1_codec_4spk;
dai_link->num_codecs = ARRAY_SIZE(ssp1_codec_4spk);
|
…onfig When the cml_rt1011_rt5682_dailink[].codecs pointer is overridden by a quirk with a devm allocated structure and the probe is deferred, in the next probe we will see an use-after-free condition (verified with KASAN). This can be avoided by using statically allocated configurations - which simplifies the code quite a bit as well. KASAN issue fixed. [ 23.301373] cml_rt1011_rt5682 cml_rt1011_rt5682: sof_rt1011_quirk = f [ 23.301875] ================================================================== [ 23.302018] BUG: KASAN: use-after-free in snd_cml_rt1011_probe+0x23a/0x3d0 [snd_soc_cml_rt1011_rt5682] [ 23.302178] Read of size 8 at addr ffff8881ec6acae0 by task kworker/0:2/105 [ 23.302320] CPU: 0 PID: 105 Comm: kworker/0:2 Not tainted 5.7.0-rc7-test+ #3 [ 23.302322] Hardware name: Google Helios/Helios, BIOS 01/21/2020 [ 23.302329] Workqueue: events deferred_probe_work_func [ 23.302331] Call Trace: [ 23.302339] dump_stack+0x76/0xa0 [ 23.302345] print_address_description.constprop.0.cold+0xd3/0x43e [ 23.302351] ? _raw_spin_lock_irqsave+0x7b/0xd0 [ 23.302355] ? _raw_spin_trylock_bh+0xf0/0xf0 [ 23.302362] ? snd_cml_rt1011_probe+0x23a/0x3d0 [snd_soc_cml_rt1011_rt5682] [ 23.302365] __kasan_report.cold+0x37/0x86 [ 23.302371] ? snd_cml_rt1011_probe+0x23a/0x3d0 [snd_soc_cml_rt1011_rt5682] [ 23.302375] kasan_report+0x38/0x50 [ 23.302382] snd_cml_rt1011_probe+0x23a/0x3d0 [snd_soc_cml_rt1011_rt5682] [ 23.302389] platform_drv_probe+0x66/0xc0 Fixes: 629ba12 ("ASoC: Intel: boards: split woofer and tweeter support") Suggested-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Signed-off-by: Fred Oh <fred.oh@linux.intel.com>
for_each_card_prelinks() is a common API to walk through each prelink in the card. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
025922d to
062af53Comparefredoh9
commented
Jun 8, 2020
@plbossart my bad, aligned again with strcmp() block. |
fredoh9
commented
Jun 9, 2020
From latest device test result, I don't see same error. |
ranj063
commented
Jun 9, 2020
@fredoh9 the device that this PR is meant for shows "Not Tested". |
fredoh9
commented
Jun 9, 2020
SOFCI TEST |
| snd_soc_card_cml.num_configs = SPK_CH; | ||
| for (i = 0; i < ARRAY_SIZE(cml_rt1011_rt5682_dailink); i++) { | ||
| if (!strcmp(cml_rt1011_rt5682_dailink[i].codecs->dai_name, |
There was a problem hiding this comment.
cml_rt1011_rt5682_dailink[i].codecs is an array, It is harmless, but I think using cml_rt1011_rt5682_dailink[i].codecs[0]->dai_name makes more sense.
There was a problem hiding this comment.
yes, this will have to be a separate patch anyway though
fredoh9
commented
Jun 9, 2020
SOFCI TEST |
fredoh9
commented
Jun 9, 2020
CI Test results are good now. |
…onfig
When the machine driver probe is deferred, the memory allocated
during probe seems to be corrupted causing the card registration to fail.
Instead of dynamic allocation for 4-channel config, statically define
2spk and 4spk and update config and codec component accordingly.
KASAN issue fixed.
[ 23.301373] cml_rt1011_rt5682 cml_rt1011_rt5682: sof_rt1011_quirk = f
[ 23.301875] ==================================================================
[ 23.302018] BUG: KASAN: use-after-free in snd_cml_rt1011_probe+0x23a/0x3d0 [snd_soc_cml_rt1011_rt5682]
[ 23.302178] Read of size 8 at addr ffff8881ec6acae0 by task kworker/0:2/105
[ 23.302320] CPU: 0 PID: 105 Comm: kworker/0:2 Not tainted 5.7.0-rc7-test+ #3
[ 23.302322] Hardware name: Google Helios/Helios, BIOS 01/21/2020
[ 23.302329] Workqueue: events deferred_probe_work_func
[ 23.302331] Call Trace:
[ 23.302339] dump_stack+0x76/0xa0
[ 23.302345] print_address_description.constprop.0.cold+0xd3/0x43e
[ 23.302351] ? _raw_spin_lock_irqsave+0x7b/0xd0
[ 23.302355] ? _raw_spin_trylock_bh+0xf0/0xf0
[ 23.302362] ? snd_cml_rt1011_probe+0x23a/0x3d0 [snd_soc_cml_rt1011_rt5682]
[ 23.302365] __kasan_report.cold+0x37/0x86
[ 23.302371] ? snd_cml_rt1011_probe+0x23a/0x3d0 [snd_soc_cml_rt1011_rt5682]
[ 23.302375] kasan_report+0x38/0x50
[ 23.302382] snd_cml_rt1011_probe+0x23a/0x3d0 [snd_soc_cml_rt1011_rt5682]
[ 23.302389] platform_drv_probe+0x66/0xc0
Suggested-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com
Signed-off-by: Fred Oh fred.oh@linux.intel.com
fixes: #2168