Skip to content

Commit

Permalink
ASoC: core: Make snd_soc_find_component() more robust
Browse files Browse the repository at this point in the history
There are some use cases where you're checking for a lot of things on a
card and it makes sense that you might end up trying to call
snd_soc_find_component() without either a name or an of_node.  Currently
in that case we try to dereference the name and crash but it's more
useful to allow the caller to just treat that as a case where we don't
find anything, that error handling will already exist.

Inspired by a patch from Ajit Pandey fixing some callers.

Fixes: 8780cf1 ("ASoC: soc-core: defer card probe until all component is added to list")
Reported-by: Pierre-Louis Bossart <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
broonie committed Jan 15, 2019
1 parent 09ac6a8 commit 5a7b2aa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ static struct snd_soc_component *soc_find_component(
if (of_node) {
if (component->dev->of_node == of_node)
return component;
} else if (strcmp(component->name, name) == 0) {
} else if (name && strcmp(component->name, name) == 0) {
return component;
}
}
Expand Down

0 comments on commit 5a7b2aa

Please sign in to comment.