diff mbox series

[2/2] ASoC: hda: don't free hda_codec for HDA_DEV_ASOC type

Message ID 20190626062935.5549-3-ranjani.sridharan@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series Fixes for SOF module unload/reload | expand

Commit Message

Ranjani Sridharan June 26, 2019, 6:29 a.m. UTC
In the case of ASoC driver, the hdac_hda_priv pointer containing
the hda_codec is device-managed. It will be freed when the
ASoC device is removed during driver unloading. Freeing
the codec in snd_hda_codec_dev_release() leads to kernel
panics while unloading and reloading the ASoC driver.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
---
 sound/pci/hda/hda_codec.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 6c51b8363f8b..a2e23d7e768f 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -846,7 +846,13 @@  static void snd_hda_codec_dev_release(struct device *dev)
 	snd_hda_sysfs_clear(codec);
 	kfree(codec->modelname);
 	kfree(codec->wcaps);
-	kfree(codec);
+
+	/*
+	 * In the case of ASoC HD-audio, hda_codec is device managed.
+	 * It will be freed when the ASoC device is removed.
+	 */
+	if (codec->core.type == HDA_DEV_LEGACY)
+		kfree(codec);
 }
 
 #define DEV_NAME_LEN 31