Skip to content

Commit

Permalink
ASoC: core: Fix possible NULL pointer dereference
Browse files Browse the repository at this point in the history
snd_soc_of_parse_card_name() may be called before card->dev has been
set, which results in a kernel panic.

Unable to handle kernel NULL pointer dereference at virtual address 00000210
PC is at snd_soc_of_parse_card_name+0x18/0x54
LR is at snow_probe+0x5c/0xd4

Add an error check in snd_soc_of_parse_card_name() to take care of this
case and print out a message in case of error.

Signed-off-by: Tushar Behera <tushar.b@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Tushar Behera authored and Mark Brown committed Jul 9, 2014
1 parent 1e4c0d7 commit 7e07e7c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -4420,9 +4420,16 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_codec);
int snd_soc_of_parse_card_name(struct snd_soc_card *card,
const char *propname)
{
struct device_node *np = card->dev->of_node;
struct device_node *np;
int ret;

if (!card->dev) {
pr_err("card->dev is not set before calling %s\n", __func__);
return -EINVAL;
}

np = card->dev->of_node;

ret = of_property_read_string_index(np, propname, 0, &card->name);
/*
* EINVAL means the property does not exist. This is fine providing
Expand Down

0 comments on commit 7e07e7c

Please sign in to comment.