From: Ranjani Sridharan Subject: [PATCH 2/2] ASoC: hda: don't free hda_codec for HDA_DEV_ASOC type Date: Tue, 25 Jun 2019 23:29:35 -0700 Message-ID: <20190626062935.5549-3-ranjani.sridharan@linux.intel.com> References: <20190626062935.5549-1-ranjani.sridharan@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 7FD60F896B7 for ; Wed, 26 Jun 2019 08:29:42 +0200 (CEST) In-Reply-To: <20190626062935.5549-1-ranjani.sridharan@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, libin.yang@intel.com, broonie@kernel.org, pierre-louis.bossart@linux.intel.com List-Id: alsa-devel@alsa-project.org 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 --- 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