Commit 02a06d30 authored by Barry Song's avatar Barry Song Committed by Mark Brown

ASoC: Fix possible codec_dai->ops NULL pointer problems

Some codec DAIs like stac9766, wm9712, wm9713, ad1980 don't register themselves
then it loses to the chance to be given a null_dai_ops in snd_soc_register_dai
if they have no ops. When functions like soc_pcm_open, soc_pcm_hw_params etc.
access the ops field in these DAIs, panic will happen.
Signed-off-by: default avatarBarry Song <21cnbao@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 8e8b2d67
...@@ -834,6 +834,9 @@ EXPORT_SYMBOL_GPL(snd_soc_resume_device); ...@@ -834,6 +834,9 @@ EXPORT_SYMBOL_GPL(snd_soc_resume_device);
#define soc_resume NULL #define soc_resume NULL
#endif #endif
static struct snd_soc_dai_ops null_dai_ops = {
};
static void snd_soc_instantiate_card(struct snd_soc_card *card) static void snd_soc_instantiate_card(struct snd_soc_card *card)
{ {
struct platform_device *pdev = container_of(card->dev, struct platform_device *pdev = container_of(card->dev,
...@@ -877,6 +880,11 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card) ...@@ -877,6 +880,11 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
ac97 = 1; ac97 = 1;
} }
for (i = 0; i < card->num_links; i++) {
if (!card->dai_link[i].codec_dai->ops)
card->dai_link[i].codec_dai->ops = &null_dai_ops;
}
/* If we have AC97 in the system then don't wait for the /* If we have AC97 in the system then don't wait for the
* codec. This will need revisiting if we have to handle * codec. This will need revisiting if we have to handle
* systems with mixed AC97 and non-AC97 parts. Only check for * systems with mixed AC97 and non-AC97 parts. Only check for
...@@ -2329,9 +2337,6 @@ static int snd_soc_unregister_card(struct snd_soc_card *card) ...@@ -2329,9 +2337,6 @@ static int snd_soc_unregister_card(struct snd_soc_card *card)
return 0; return 0;
} }
static struct snd_soc_dai_ops null_dai_ops = {
};
/** /**
* snd_soc_register_dai - Register a DAI with the ASoC core * snd_soc_register_dai - Register a DAI with the ASoC core
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment