ASoC: Intel: Skylake: Check the kcontrol against NULL
Subsystems (4)
PATCH 1/1 ASoC: Intel: Skylake: Check the kcontrol against NULL
There is no check for the kcontrol against NULL and in some cases it causes kernel to crash.
--- sound/soc/intel/skylake/skl-topology.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
sound/soc/intel/skylake/skl-topology.c +10 -4
@@ -3618,12 +3618,18 @@ static void skl_tplg_complete(struct snd_soc_component *component)int i;list_for_each_entry (dobj, &component->dobj_list, list) { -struct snd_kcontrol *kcontrol = dobj->control.kcontrol; -struct soc_enum *se = - (struct soc_enum *)kcontrol->private_value; -char **texts = dobj->control.dtexts; +struct snd_kcontrol *kcontrol; +struct soc_enum *se; +char **texts;char chan_text[4 ]; + kcontrol = dobj->control.kcontrol; +if (!kcontrol) +continue ; + + se = (struct soc_enum *)kcontrol->private_value; + texts = dobj->control.dtexts; +if (dobj->type !=SND_SOC_DOBJ_ENUM || dobj->control.kcontrol->put != skl_tplg_multi_config_set_dmic)
base-commit: 69fe63aa100220c8fd1f451dd54dd0895df1441d
Signature · 1 line
2.25.1
Quoted 39 lines
There is no check for the kcontrol against NULL and in some cases it causes kernel to crash.
Fixes 2d744ecf2b984 ("ASoC: Intel: Skylake: Automatic DMIC format configuration according to information from NHLT")Cc <[email protected]> # 5.4+Signed-off-by Lukasz Majczak <[email protected]>--- sound/soc/intel/skylake/skl-topology.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)sound/soc/intel/skylake/skl-topology.c +10
-4@@ -3618,12 +3618,18 @@ static void skl_tplg_complete(struct snd_soc_component *component)int i;list_for_each_entry (dobj, &component->dobj_list, list) { -struct snd_kcontrol *kcontrol = dobj->control.kcontrol; -struct soc_enum *se = - (struct soc_enum *)kcontrol->private_value; -char **texts = dobj->control.dtexts; +struct snd_kcontrol *kcontrol; +struct soc_enum *se; +char **texts;char chan_text[4 ]; + kcontrol = dobj->control.kcontrol; +if (!kcontrol) +continue ; + + se = (struct soc_enum *)kcontrol->private_value; + texts = dobj->control.dtexts; +if (dobj->type !=SND_SOC_DOBJ_ENUM || dobj->control.kcontrol->put != skl_tplg_multi_config_set_dmic)
Quoted 1 line
base-commit:
69fe63aa100220c8fd1f451dd54dd0895df1441d
Thanks for pointing out and fixing this. This check was obviously missing there. I did a quick verification on few of our platforms, encountered no issues, so:
Also, could you please:
- describe the affected configuration (used machine driver or audio card name, device name),
- share full dmesg logs from one of said crashes,
- copy the output of "amixer -c0 controls" command executed on affected device.
These would be useful information for us to further improve our validation and help us with debugging.
Thanks,
Mateusz
Quoted 49 lines · Mateusz
Quoted 5 lines
There is no check for the kcontrol against NULL and in some cases it causes kernel to crash.
Fixes 2d744ecf2b984 ("ASoC: Intel: Skylake: Automatic DMIC formatconfiguration according to information from NHLT")
Review
Quoted 7 lines
Cc <[email protected]> # 5.4+Signed-off-by Lukasz Majczak <[email protected]>--- sound/soc/intel/skylake/skl-topology.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/sound/soc/intel/skylake/skl-topology.csound/soc/intel/skylake/skl-topology.c static void skl_tplg_complete(struct
Quoted 4 lines
index
ae466cd592922..c9abbe4ff0ba3100644sound/soc/intel/skylake/skl-topology.c +0
-0@@ -3618,12 +3618,18 @@ static void skl_tplg_complete(struct
snd_soc_component*component)Quoted 23 lines
sound/soc/intel/skylake/skl-topology.c +10
-4int i;list_for_each_entry (dobj, &component->dobj_list, list) { -struct snd_kcontrol *kcontrol = dobj->control.kcontrol; -struct soc_enum *se = - (struct soc_enum *)kcontrol->private_value; -char **texts = dobj->control.dtexts; +struct snd_kcontrol *kcontrol; +struct soc_enum *se; +char **texts;char chan_text[4 ]; + kcontrol = dobj->control.kcontrol; +if (!kcontrol) +continue ; + + se = (struct soc_enum *)kcontrol->private_value; + texts = dobj->control.dtexts; +if (dobj->type !=SND_SOC_DOBJ_ENUM || dobj->control.kcontrol->put != skl_tplg_multi_config_set_dmic)Quoted 1 line
base-commit:
69fe63aa100220c8fd1f451dd54dd0895df1441dThanks for pointing out and fixing this. This check was obviously missing there. I did a quick verification on few of our platforms, encountered no issues, so:
Quoted 8 lines
Reviewed-by Mateusz Gorski <[email protected]>Also, could you please:
- describe the affected configuration (used machine driver or audio card name, device name),
Primarily Google Pixelbook. However, this can happen whenever dobj->type != SND_SOC_DOBJ_ENUM. For many of those other types, kcontrol is not set. It is pure luck that the problem is not seen everywhere,
and it seems to be compiler dependent. [Some compilers or compiler versions only assign se when needed, ie after the if() statement].
Guenter
Quoted 14 lines
- share full dmesg logs from one of said crashes,
- copy the output of "amixer -c0 controls" command executed on affected device.These would be useful information for us to further improve our validation and help us with debugging.
Thanks,
Mateusz
sound/soc/intel/skylake/skl-topology.c static void skl_tplg_complete(struct snd_soc_component *component) · line 3628
Quoted 3 lines · Lukasz Majczak
sound/soc/intel/skylake/skl-topology.c +3
-0+ kcontrol = dobj->control.kcontrol; +if (!kcontrol) +continue ;
Small nitpick, there should be space between if and opening parenthesis as recommended by coding style.
Thanks,
Amadeusz
PATCH v2 1/1 ASoC: Intel: Skylake: Check the kcontrol against NULL
In reply to Lukasz MajczakThere is no check for the kcontrol against NULL and in some cases it causes kernel to crash.
--- sound/soc/intel/skylake/skl-topology.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
v1 -> v2: fixed coding style
sound/soc/intel/skylake/skl-topology.c +10 -4
@@ -3618,12 +3618,18 @@ static void skl_tplg_complete(struct snd_soc_component *component)int i;list_for_each_entry (dobj, &component->dobj_list, list) { -struct snd_kcontrol *kcontrol = dobj->control.kcontrol; -struct soc_enum *se = - (struct soc_enum *)kcontrol->private_value; -char **texts = dobj->control.dtexts; +struct snd_kcontrol *kcontrol; +struct soc_enum *se; +char **texts;char chan_text[4 ]; + kcontrol = dobj->control.kcontrol; +if (!kcontrol) +continue ; + + se = (struct soc_enum *)kcontrol->private_value; + texts = dobj->control.dtexts; +if (dobj->type !=SND_SOC_DOBJ_ENUM || dobj->control.kcontrol->put != skl_tplg_multi_config_set_dmic)
Signature · 1 line
2.25.1
Hi,
This is just a kind reminder. Is there anything more required to upstream this patch?
Best regards,
Lukasz
czw., 17 gru 2020 o 14:06 Lukasz Majczak <[email protected]> napisał(a):
Quoted 43 lines
There is no check for the kcontrol against NULL and in some cases it causes kernel to crash.
Fixes 2d744ecf2b984 ("ASoC: Intel: Skylake: Automatic DMIC format configuration according to information from NHLT")Cc <[email protected]> # 5.4+Signed-off-by Lukasz Majczak <[email protected]>Reviewed-by Mateusz Gorski <[email protected]>--- sound/soc/intel/skylake/skl-topology.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)v1 -> v2: fixed coding style
sound/soc/intel/skylake/skl-topology.c +10
-5@@ -3618,12 +3618,18 @@ static void skl_tplg_complete(struct snd_soc_component *component)int i;list_for_each_entry (dobj, &component->dobj_list, list) { -struct snd_kcontrol *kcontrol = dobj->control.kcontrol; -struct soc_enum *se = - (struct soc_enum *)kcontrol->private_value; -char **texts = dobj->control.dtexts; +struct snd_kcontrol *kcontrol; +struct soc_enum *se; +char **texts;char chan_text[4 ]; + kcontrol = dobj->control.kcontrol; +if (!kcontrol) +continue ; + + se = (struct soc_enum *)kcontrol->private_value; + texts = dobj->control.dtexts; +if (dobj->type !=SND_SOC_DOBJ_ENUM || dobj->control.kcontrol->put != skl_tplg_multi_config_set_dmic) --2.25.1
Hi Pierre,
Is there anything more to do to get the ACK for this patch?
Best regards,
Lukasz
wt., 12 sty 2021 o 12:34 Łukasz Majczak <[email protected]> napisał(a):
Quoted 54 lines
Hi,
This is just a kind reminder. Is there anything more required to upstream this patch?
Best regards,
Lukaszczw., 17 gru 2020 o 14:06 Lukasz Majczak <[email protected]> napisał(a):
Quoted 43 lines
There is no check for the kcontrol against NULL and in some cases it causes kernel to crash.
Fixes 2d744ecf2b984 ("ASoC: Intel: Skylake: Automatic DMIC format configuration according to information from NHLT")Cc <[email protected]> # 5.4+Signed-off-by Lukasz Majczak <[email protected]>Reviewed-by Mateusz Gorski <[email protected]>--- sound/soc/intel/skylake/skl-topology.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)v1 -> v2: fixed coding style
sound/soc/intel/skylake/skl-topology.c +10
-5@@ -3618,12 +3618,18 @@ static void skl_tplg_complete(struct snd_soc_component *component)int i;list_for_each_entry (dobj, &component->dobj_list, list) { -struct snd_kcontrol *kcontrol = dobj->control.kcontrol; -struct soc_enum *se = - (struct soc_enum *)kcontrol->private_value; -char **texts = dobj->control.dtexts; +struct snd_kcontrol *kcontrol; +struct soc_enum *se; +char **texts;char chan_text[4 ]; + kcontrol = dobj->control.kcontrol; +if (!kcontrol) +continue ; + + se = (struct soc_enum *)kcontrol->private_value; + texts = dobj->control.dtexts; +if (dobj->type !=SND_SOC_DOBJ_ENUM || dobj->control.kcontrol->put != skl_tplg_multi_config_set_dmic) --2.25.1
Quoted 3 lines · Łukasz Majczak
Hi Pierre,
Is there anything more to do to get the ACK for this patch?
Adding Cezary and Amadeusz for feedback, I can't pretend having any sort of knowledge on the Skylake driver internals and topology usage.
Quoted 58 lines
Best regards,
Lukaszwt., 12 sty 2021 o 12:34 Łukasz Majczak <[email protected]> napisał(a):
Quoted 54 lines
Hi,
This is just a kind reminder. Is there anything more required to upstream this patch?
Best regards,
Lukaszczw., 17 gru 2020 o 14:06 Lukasz Majczak <[email protected]> napisał(a):
Quoted 43 lines
There is no check for the kcontrol against NULL and in some cases it causes kernel to crash.
Fixes 2d744ecf2b984 ("ASoC: Intel: Skylake: Automatic DMIC format configuration according to information from NHLT")Cc <[email protected]> # 5.4+Signed-off-by Lukasz Majczak <[email protected]>Reviewed-by Mateusz Gorski <[email protected]>--- sound/soc/intel/skylake/skl-topology.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)v1 -> v2: fixed coding style
sound/soc/intel/skylake/skl-topology.c +10
-5@@ -3618,12 +3618,18 @@ static void skl_tplg_complete(struct snd_soc_component *component)int i;list_for_each_entry (dobj, &component->dobj_list, list) { -struct snd_kcontrol *kcontrol = dobj->control.kcontrol; -struct soc_enum *se = - (struct soc_enum *)kcontrol->private_value; -char **texts = dobj->control.dtexts; +struct snd_kcontrol *kcontrol; +struct soc_enum *se; +char **texts;char chan_text[4 ]; + kcontrol = dobj->control.kcontrol; +if (!kcontrol) +continue ; + + se = (struct soc_enum *)kcontrol->private_value; + texts = dobj->control.dtexts; +if (dobj->type !=SND_SOC_DOBJ_ENUM || dobj->control.kcontrol->put != skl_tplg_multi_config_set_dmic) --2.25.1
Rojewski, Cezary
maintainerQuoted 8 lines · Pierre-Louis Bossart
Quoted 3 lines · Łukasz Majczak
Hi Pierre,
Is there anything more to do to get the ACK for this patch?
Adding Cezary and Amadeusz for feedback, I can't pretend having any sort of knowledge on the Skylake driver internals and topology usage.
Thanks for the CC, Pierre.
...
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
sound/soc/intel/skylake/skl-topology.c +3
-4@@ -3618,12 +3618,18 @@ static void skl_tplg_complete(struct snd_soc_component *component)int i;list_for_each_entry (dobj, &component->dobj_list, list) { -struct snd_kcontrol *kcontrol = dobj->control.kcontrol; -struct soc_enum *se = - (struct soc_enum *)kcontrol->private_value; -char **texts = dobj->control.dtexts; +struct snd_kcontrol *kcontrol; +struct soc_enum *se; +char **texts;char chan_text[4 ];
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
sound/soc/intel/skylake/skl-topology.c +7
-0+ kcontrol = dobj->control.kcontrol; +if (!kcontrol) +continue ; + + se = (struct soc_enum *)kcontrol->private_value; + texts = dobj->control.dtexts; +if (dobj->type !=SND_SOC_DOBJ_ENUM || dobj->control.kcontrol->put !=
skl_tplg_multi_config_set_dmic)
Just checked the history behind this. And must say, I liked Ricardo's version better. Except for the "= {};" bit which Mark already pointed out - it should be a separate fix - it's simply more optional
e.g.: 'kcontrol' gets assigned yet 'if' above is not updated accordingly:
s/dobj->control.kcontrol->put/kcontrol->put
Czarek
Rojewski, Cezary
maintainerQuoted 4 lines · Cezary
Just checked the history behind this. And must say, I liked Ricardo's version better. Except for the "= {};" bit which Mark already pointed out - it should be a separate fix - it's simply more optional
Meant to say: optimal.