* [PATCH] ASoC: dapm: Do not traverse widget hooks to snd-soc-dummy
@ 2016-03-16 11:17 Harry Pan
2016-03-17 9:54 ` Mark Brown
0 siblings, 1 reply; 8+ messages in thread
From: Harry Pan @ 2016-03-16 11:17 UTC (permalink / raw)
To: LKML; +Cc: Harry Pan, Harry Pan, lgirdwood, broonie, perex, tiwai,
alsa-devel
All components are initially given an empty card when registering platform,
and since the commit 6e78108bda78
("ASoC: core: Don't probe the component which is dummy")',
snd-soc-dummy will not be probed so that it remains an empty card assigned.
This patch ignores to iterate widget hooks to the 'snd-soc-dummy'
component, else it will trigger memory fault because of invalid dereference
address of card->widgets.
Test by grep -rsI "hello" /sys/devices/platform/skl_nau88l25_ssm4567_i2s/
Conflicts:
sound/soc/soc-dapm.c
Signed-off-by: Harry Pan <harry.pan@intel.com>
---
sound/soc/soc-dapm.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 581175a..0bc15c9 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2188,6 +2188,9 @@ static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt,
int count = 0;
char *state = "not set";
+ if (!strcmp(cmpnt->name, "snd-soc-dummy"))
+ return 0;
+
list_for_each_entry(w, &cmpnt->card->widgets, list) {
if (w->dapm != dapm)
continue;
--
2.1.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] ASoC: dapm: Do not traverse widget hooks to snd-soc-dummy
2016-03-16 11:17 [PATCH] ASoC: dapm: Do not traverse widget hooks to snd-soc-dummy Harry Pan
@ 2016-03-17 9:54 ` Mark Brown
2016-03-17 10:38 ` Pan, Harry
0 siblings, 1 reply; 8+ messages in thread
From: Mark Brown @ 2016-03-17 9:54 UTC (permalink / raw)
To: Harry Pan; +Cc: LKML, Harry Pan, lgirdwood, perex, tiwai, alsa-devel
[-- Attachment #1: Type: text/plain, Size: 553 bytes --]
On Wed, Mar 16, 2016 at 07:17:51PM +0800, Harry Pan wrote:
> Conflicts:
> sound/soc/soc-dapm.c
Don't include noise like this in upstream submissions.
> + if (!strcmp(cmpnt->name, "snd-soc-dummy"))
> + return 0;
> +
This doesn't make much sense and is going to be very fragile. We
should either make the dummy component look like other components or
make the code cope with them as they stand, that way we don't have
random undocumented special cases scattered through the code. Probably
it's better to make the dummy component look like others.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ASoC: dapm: Do not traverse widget hooks to snd-soc-dummy
2016-03-17 9:54 ` Mark Brown
@ 2016-03-17 10:38 ` Pan, Harry
2016-03-17 11:25 ` Mark Brown
0 siblings, 1 reply; 8+ messages in thread
From: Pan, Harry @ 2016-03-17 10:38 UTC (permalink / raw)
To: broonie@kernel.org
Cc: lgirdwood@gmail.com, linux-kernel@vger.kernel.org,
gs0622@gmail.com, alsa-devel@alsa-project.org, tiwai@suse.com,
perex@perex.cz
On Thu, 2016-03-17 at 09:54 +0000, Mark Brown wrote:
> On Wed, Mar 16, 2016 at 07:17:51PM +0800, Harry Pan wrote:
>
> > Conflicts:
> > sound/soc/soc-dapm.c
>
> Don't include noise like this in upstream submissions.
>
I learned, thanks.
> > + if (!strcmp(cmpnt->name, "snd-soc-dummy"))
> > + return 0;
> > +
>
> This doesn't make much sense and is going to be very fragile. We
> should either make the dummy component look like other components or
> make the code cope with them as they stand, that way we don't have
> random undocumented special cases scattered through the code. Probably
> it's better to make the dummy component look like others.
I do agree, basically.
Allow me to explain more detail that I saw during debug; since the
commit 6e78108bda78 (ASoC: core: Don't probe the component which is
dummy), an exception has been made that dummy component won't be probed,
thus the 'card' passed into soc_probe_component() would not be assigned
to this component. In the other hand, the component struct is initially
created in snd_soc_register_platform() by kzalloc() of platform struct,
its 'card' pointer is remaining an NULL pointer even the widget node
being read.
Perhaps another option is to refine soc_probe_component(), which I have
not dive in.
Sincerely,
Harry
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ASoC: dapm: Do not traverse widget hooks to snd-soc-dummy
2016-03-17 10:38 ` Pan, Harry
@ 2016-03-17 11:25 ` Mark Brown
2016-03-17 12:37 ` Lars-Peter Clausen
0 siblings, 1 reply; 8+ messages in thread
From: Mark Brown @ 2016-03-17 11:25 UTC (permalink / raw)
To: Pan, Harry
Cc: lgirdwood@gmail.com, linux-kernel@vger.kernel.org,
gs0622@gmail.com, alsa-devel@alsa-project.org, tiwai@suse.com,
perex@perex.cz
[-- Attachment #1: Type: text/plain, Size: 994 bytes --]
On Thu, Mar 17, 2016 at 10:38:36AM +0000, Pan, Harry wrote:
> Allow me to explain more detail that I saw during debug; since the
> commit 6e78108bda78 (ASoC: core: Don't probe the component which is
> dummy), an exception has been made that dummy component won't be probed,
> thus the 'card' passed into soc_probe_component() would not be assigned
> to this component. In the other hand, the component struct is initially
> created in snd_soc_register_platform() by kzalloc() of platform struct,
> its 'card' pointer is remaining an NULL pointer even the widget node
> being read.
> Perhaps another option is to refine soc_probe_component(), which I have
> not dive in.
Another approach might be to create a separate dummy component for each
card rather than trying to reuse the same one for all of them (which was
what the commit you mention was doing) - that way we don't need to worry
about it getting added to multiple cards which was the original problem
that was being looked at here.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ASoC: dapm: Do not traverse widget hooks to snd-soc-dummy
2016-03-17 11:25 ` Mark Brown
@ 2016-03-17 12:37 ` Lars-Peter Clausen
2016-03-17 13:04 ` Pan, Harry
2016-03-17 15:42 ` Mark Brown
0 siblings, 2 replies; 8+ messages in thread
From: Lars-Peter Clausen @ 2016-03-17 12:37 UTC (permalink / raw)
To: Mark Brown, Pan, Harry
Cc: lgirdwood@gmail.com, linux-kernel@vger.kernel.org,
gs0622@gmail.com, alsa-devel@alsa-project.org, tiwai@suse.com,
perex@perex.cz
[-- Attachment #1: Type: text/plain, Size: 1349 bytes --]
On 03/17/2016 12:25 PM, Mark Brown wrote:
> On Thu, Mar 17, 2016 at 10:38:36AM +0000, Pan, Harry wrote:
>
>> Allow me to explain more detail that I saw during debug; since the
>> commit 6e78108bda78 (ASoC: core: Don't probe the component which is
>> dummy), an exception has been made that dummy component won't be probed,
>> thus the 'card' passed into soc_probe_component() would not be assigned
>> to this component. In the other hand, the component struct is initially
>> created in snd_soc_register_platform() by kzalloc() of platform struct,
>> its 'card' pointer is remaining an NULL pointer even the widget node
>> being read.
>
>> Perhaps another option is to refine soc_probe_component(), which I have
>> not dive in.
>
> Another approach might be to create a separate dummy component for each
> card rather than trying to reuse the same one for all of them (which was
> what the commit you mention was doing) - that way we don't need to worry
> about it getting added to multiple cards which was the original problem
> that was being looked at here.
I'd say as a quick fix for stable check that card is not NULL in
dapm_widget_show_component(). And as a longterm fix get rid of dapm_widget
file. Nobody should hopefully use it anymore with debugfs being available as
the far better alternative.
- Lars
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ASoC: dapm: Do not traverse widget hooks to snd-soc-dummy
2016-03-17 12:37 ` Lars-Peter Clausen
@ 2016-03-17 13:04 ` Pan, Harry
2016-03-17 15:42 ` Mark Brown
1 sibling, 0 replies; 8+ messages in thread
From: Pan, Harry @ 2016-03-17 13:04 UTC (permalink / raw)
To: lars@metafoo.de, broonie@kernel.org
Cc: lgirdwood@gmail.com, linux-kernel@vger.kernel.org,
gs0622@gmail.com, alsa-devel@alsa-project.org, tiwai@suse.com,
perex@perex.cz
> I'd say as a quick fix for stable check that card is not NULL in
> dapm_widget_show_component(). And as a longterm fix get rid of
> dapm_widget
> file. Nobody should hopefully use it anymore with debugfs being
> available as
> the far better alternative.
>
> - Lars
Well, that was my original approach while I realized problem
is caused by de-referencing a null pointer to its member of
'widget' list.
i.e.
https://chromium-review.googlesource.com/#/c/331285/3/sound/soc/soc-dap
m.c
+ if (WARN_ON(!codec->component.card))
+ return 0;
+
Additional remark is that I was working on chromium-os v3.18 kernel,
so that the interface and argument are sort of different than what
I then cherry-pick'ed then sent, which was based on latest 4.5.
Then I was stuck at here couple days keeping hunting root cause,
Turned out I found that commit skipped probing dummy component.
Long story short.
-Harry
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ASoC: dapm: Do not traverse widget hooks to snd-soc-dummy
2016-03-17 12:37 ` Lars-Peter Clausen
2016-03-17 13:04 ` Pan, Harry
@ 2016-03-17 15:42 ` Mark Brown
2016-03-18 5:17 ` [alsa-devel] " Vinod Koul
1 sibling, 1 reply; 8+ messages in thread
From: Mark Brown @ 2016-03-17 15:42 UTC (permalink / raw)
To: Lars-Peter Clausen
Cc: Pan, Harry, lgirdwood@gmail.com, linux-kernel@vger.kernel.org,
gs0622@gmail.com, alsa-devel@alsa-project.org, tiwai@suse.com,
perex@perex.cz
[-- Attachment #1: Type: text/plain, Size: 542 bytes --]
On Thu, Mar 17, 2016 at 01:37:16PM +0100, Lars-Peter Clausen wrote:
> I'd say as a quick fix for stable check that card is not NULL in
> dapm_widget_show_component(). And as a longterm fix get rid of dapm_widget
> file. Nobody should hopefully use it anymore with debugfs being available as
> the far better alternative.
Getting rid of the file is definitely not a bad idea but I'd still like
to see us make the dummy component more consistent with other components
in order to minimise the chances that we'll run into other special
cases.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [alsa-devel] [PATCH] ASoC: dapm: Do not traverse widget hooks to snd-soc-dummy
2016-03-17 15:42 ` Mark Brown
@ 2016-03-18 5:17 ` Vinod Koul
0 siblings, 0 replies; 8+ messages in thread
From: Vinod Koul @ 2016-03-18 5:17 UTC (permalink / raw)
To: Mark Brown, Lars-Peter Clausen
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
tiwai@suse.com, lgirdwood@gmail.com, Pan, Harry, gs0622@gmail.com
On Thursday 17 March 2016 09:12 PM, Mark Brown wrote:
> On Thu, Mar 17, 2016 at 01:37:16PM +0100, Lars-Peter Clausen wrote:
>
>> I'd say as a quick fix for stable check that card is not NULL in
>> dapm_widget_show_component(). And as a longterm fix get rid of dapm_widget
>> file. Nobody should hopefully use it anymore with debugfs being available as
>> the far better alternative.
>
> Getting rid of the file is definitely not a bad idea but I'd still like
> to see us make the dummy component more consistent with other components
> in order to minimise the chances that we'll run into other special
> cases.
Right, I do see that we need dummy component to be fixed up. Today if we
use dummy twice in a card it refers to same instance whereas IMO it
should create separate instances. I will try something on these lines in
next month or so...
--
~Vinod
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-03-18 5:12 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-16 11:17 [PATCH] ASoC: dapm: Do not traverse widget hooks to snd-soc-dummy Harry Pan
2016-03-17 9:54 ` Mark Brown
2016-03-17 10:38 ` Pan, Harry
2016-03-17 11:25 ` Mark Brown
2016-03-17 12:37 ` Lars-Peter Clausen
2016-03-17 13:04 ` Pan, Harry
2016-03-17 15:42 ` Mark Brown
2016-03-18 5:17 ` [alsa-devel] " Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox