From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794585921; b=3g7LvTwwdplbqZPMUll8KKBIEO55Y6/+Kcr7PlBiakj6LD+5q09zKDkuCjxCfL1YdMt7 nC0uf/ZSPkOd0myN2UWosVU0XkDeSqPRphk/p0sbd2KNR3zeL0OPi/0ZOl5FRVMFPeTew YjpUyYmh4AZBUfl3TfjOBvySp5g8pIryBsI4xtV850LobRnVzUVk8eBt29a9KW6cxz4dZ X0wshLmxzJZyZNcc5JpyoxLD3yLIBOGOo1nHW27xhIlPXiyWomhvarPU5J4KevLGxmHDS dRhiYpj3P9fGKaMg4d06cFzaz+4sI/Lax2jVbj9Z+qGmWe7uEshhsOHkoQ7/IEJ78yg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794585921; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=3idoxSO141hfiDKVvnnZmkHgEGsqyyfmyHTgnYzsGwU=; b=LwYFo0gTFi80tXl6jb4klVPCHr2gnzFFxTU+oAaxnYsdf0cRcbaTbJvHuGgxj+ijYR4K UdHPu/7VD2Cck4U6OamR70aogGoM6fbNnPwk2hxGbG1I2ttXFSPMT9iD4MidGnFcdhPf8 Z0o5ah3dkG/sot6fpya+d+fKv3RpaFftjvPA9Sh/6J9ys/tjpgAIMznlcz3l8IvUCG9m3 YcOCL8q+U4ByIMGYR2/B6LPMoXU7JNSsDOX6lMSCZI7z7BrlrUVz0Ao2CivNOEAtHcTEy StszUR5byEeFR1JM9YhUrWZuSg8gRKyW4fHPA38zZQHfiph36nrHzbrm4d+4Bixh9XA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=vzCqjvj4; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3657606A895; Fri, 13 Nov 2026 16:05:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=vzCqjvj4 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C2D21F000C4; Fri, 13 Nov 2026 16:05:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794585921; bh=3idoxSO141hfiDKVvnnZmkHgEGsqyyfmyHTgnYzsGwU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vzCqjvj4Qy/i2BN5M8zcrEnuIVYB32FOMLYuwnV6asaGFMcRI9XSc1J7LX4Z9X9cy cGUcWskcegegUaYsykCJwNydSUtajhBwRPvH/8XJd1n4df2sLUVQ5ed5BX2AJJPMSd EoKejUkdDufJrouwknjc9FVpVnh+3BI61ceRurS8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Peter Ujfalusi , Mark Brown , Sasha Levin Subject: [PATCH 7.3 482/507] ASoC: hdac_hda: Allocate the private data at codec driver bind Date: Fri, 13 Nov 2026 10:53:06 -0500 Message-ID: <20261113153813.400920262@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261113153753.358973689@linuxfoundation.org> References: <20261113153753.358973689@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Peter Ujfalusi [ Upstream commit 7d357eae973a1e1933f81f55aa1b3b4e3064570f ] The SOF HDA code allocates struct hdac_hda_priv and stores it as drvdata of the codec device before the codec driver is bound. The driver core clears drvdata on unbind, so after unbinding the codec driver via sysfs a subsequent bind dereferences a NULL pointer in hdac_hda_dev_probe(). All information in the private data can be derived from the codec device itself, so allocate and set it up in hdac_hda_dev_probe() as a device managed resource, which is released on unbind. Remove the allocation from SOF, keeping the check for iDisp codecs without display audio component. Fixes: 3fd63658caed ("ASoC: Intel: Drop hdac_ext usage for codec device creation") Signed-off-by: Peter Ujfalusi Link: https://patch.msgid.link/20261027083840.28813-2-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown Stable-dep-of: 08a44bde821d ("ASoC: hdac_hda: Restore the codec device type on unbind") Signed-off-by: Sasha Levin --- sound/soc/codecs/hdac_hda.c | 13 ++++++++++++- sound/soc/sof/intel/hda-codec.c | 23 ++++------------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/sound/soc/codecs/hdac_hda.c b/sound/soc/codecs/hdac_hda.c index 40d602f79314a..0604315a1f0f3 100644 --- a/sound/soc/codecs/hdac_hda.c +++ b/sound/soc/codecs/hdac_hda.c @@ -635,10 +635,21 @@ static const struct snd_soc_component_driver hdac_hda_hdmi_codec = { static int hdac_hda_dev_probe(struct hdac_device *hdev) { - struct hdac_hda_priv *hda_pvt = dev_get_drvdata(&hdev->dev); + struct hdac_hda_priv *hda_pvt; struct hdac_ext_link *hlink; int ret; + hda_pvt = devm_kzalloc(&hdev->dev, sizeof(*hda_pvt), GFP_KERNEL); + if (!hda_pvt) + return -ENOMEM; + + hda_pvt->codec = dev_to_hda_codec(&hdev->dev); + hda_pvt->dev_index = hdev->addr; + /* Intel iDisp (HDMI/DP) codec */ + if (((hdev->vendor_id >> 16) & 0xFFFF) == 0x8086) + hda_pvt->need_display_power = true; + dev_set_drvdata(&hdev->dev, hda_pvt); + /* hold the ref while we probe */ hlink = snd_hdac_ext_bus_get_hlink_by_name(hdev->bus, dev_name(&hdev->dev)); if (!hlink) { diff --git a/sound/soc/sof/intel/hda-codec.c b/sound/soc/sof/intel/hda-codec.c index fd371850b0d69..32fcc1cd3f923 100644 --- a/sound/soc/sof/intel/hda-codec.c +++ b/sound/soc/sof/intel/hda-codec.c @@ -15,8 +15,6 @@ #include "hda.h" #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC) -#include "../../codecs/hdac_hda.h" - #define CODEC_PROBE_RETRIES 3 #define IDISP_VID_INTEL 0x80860000 @@ -148,7 +146,6 @@ static struct hda_codec *hda_codec_device_init(struct hdac_bus *bus, int addr, i /* probe individual codec */ static int hda_codec_probe(struct snd_sof_dev *sdev, int address) { - struct hdac_hda_priv *hda_priv; struct hda_bus *hbus = sof_to_hbus(sdev); struct hda_codec *codec; u32 hda_cmd = (address << 28) | (AC_NODE_ROOT << 20) | @@ -168,27 +165,15 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address) dev_dbg(sdev->dev, "HDA codec #%d probed OK: response: %x\n", address, resp); - hda_priv = devm_kzalloc(sdev->dev, sizeof(*hda_priv), GFP_KERNEL); - if (!hda_priv) - return -ENOMEM; - codec = hda_codec_device_init(&hbus->core, address, HDA_DEV_LEGACY); ret = PTR_ERR_OR_ZERO(codec); if (ret < 0) return ret; - hda_priv->codec = codec; - hda_priv->dev_index = address; - dev_set_drvdata(&codec->core.dev, hda_priv); - - if ((resp & 0xFFFF0000) == IDISP_VID_INTEL) { - if (!hbus->core.audio_component) { - dev_dbg(sdev->dev, - "iDisp hw present but no driver\n"); - ret = -ENOENT; - goto out; - } - hda_priv->need_display_power = true; + if ((resp & 0xFFFF0000) == IDISP_VID_INTEL && !hbus->core.audio_component) { + dev_dbg(sdev->dev, "iDisp hw present but no driver\n"); + ret = -ENOENT; + goto out; } if (is_generic_config(hbus)) -- 2.53.0