[alsa-devel] [PATCH 2/2] ASoC: hda: don't free hda_codec for HDA_DEV_ASOC type
Ranjani Sridharan
ranjani.sridharan at linux.intel.com
Wed Jun 26 08:29:35 CEST 2019
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 at linux.intel.com>
---
sound/pci/hda/hda_codec.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
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
--
2.17.1
More information about the Alsa-devel
mailing list