diff options
author | Tushar Behera <tushar.b@samsung.com> | 2014-07-04 04:53:00 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-07-09 04:06:46 -0400 |
commit | 7e07e7c0854b32181b314f5ba43007629594663a (patch) | |
tree | 4445c7b2fe423b4f14503e47d62ef52c05106154 /sound/soc/soc-core.c | |
parent | 1e4c0d7c9a2b44e18fe9e93712672741f70e36da (diff) |
ASoC: core: Fix possible NULL pointer dereference
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>
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r-- | sound/soc/soc-core.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index b87d7d882e6d..63d11071fdba 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -4420,9 +4420,16 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_codec); | |||
4420 | int snd_soc_of_parse_card_name(struct snd_soc_card *card, | 4420 | int snd_soc_of_parse_card_name(struct snd_soc_card *card, |
4421 | const char *propname) | 4421 | const char *propname) |
4422 | { | 4422 | { |
4423 | struct device_node *np = card->dev->of_node; | 4423 | struct device_node *np; |
4424 | int ret; | 4424 | int ret; |
4425 | 4425 | ||
4426 | if (!card->dev) { | ||
4427 | pr_err("card->dev is not set before calling %s\n", __func__); | ||
4428 | return -EINVAL; | ||
4429 | } | ||
4430 | |||
4431 | np = card->dev->of_node; | ||
4432 | |||
4426 | ret = of_property_read_string_index(np, propname, 0, &card->name); | 4433 | ret = of_property_read_string_index(np, propname, 0, &card->name); |
4427 | /* | 4434 | /* |
4428 | * EINVAL means the property does not exist. This is fine providing | 4435 | * EINVAL means the property does not exist. This is fine providing |