diff options
author | Takashi Iwai <tiwai@suse.de> | 2015-02-27 17:57:55 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2015-03-03 11:26:27 +0100 |
commit | 61ca4107a16828559e2463e49b87002990da0b98 (patch) | |
tree | fb8dc9b71ec90beeb1f5bae529e6c54ca8189709 /sound/pci/hda/hda_codec.c | |
parent | bbbc7e8502c95237dbd86cc4d0a12ca9a6b18c8f (diff) |
ALSA: hda - Don't assume non-NULL PCM ops
The PCM ops might be set NULL, or cleared to NULL when the driver is
unbound. Give a proper NULL check at each place to be more robust.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r-- | sound/pci/hda/hda_codec.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 20283bead10a..3bd9158addc2 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -4525,7 +4525,11 @@ int snd_hda_codec_prepare(struct hda_codec *codec, { int ret; mutex_lock(&codec->bus->prepare_mutex); - ret = hinfo->ops.prepare(hinfo, codec, stream, format, substream); + if (hinfo->ops.prepare) + ret = hinfo->ops.prepare(hinfo, codec, stream, format, + substream); + else + ret = -ENODEV; if (ret >= 0) purify_inactive_streams(codec); mutex_unlock(&codec->bus->prepare_mutex); @@ -4546,7 +4550,8 @@ void snd_hda_codec_cleanup(struct hda_codec *codec, struct snd_pcm_substream *substream) { mutex_lock(&codec->bus->prepare_mutex); - hinfo->ops.cleanup(hinfo, codec, substream); + if (hinfo->ops.cleanup) + hinfo->ops.cleanup(hinfo, codec, substream); mutex_unlock(&codec->bus->prepare_mutex); } EXPORT_SYMBOL_GPL(snd_hda_codec_cleanup); |