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=1795038688; b=iktIfl3lmTb8aLfcMgnhsUP1onTt03xztqTzKFLALmQ0XTogOb5Iqc4TOajW+nQ+ar47 PPsjbgZrlT7fUNn/W0BTrDM/HDks7OMyEi10WP8k/4X3Nj+cMAdD7c7GJHziRMMYvXOoq 9+UDqithlk4pBOoG7SJ9gHDdnQePegrtlLePYmDh8z9Hrzld4EJgDiR/JQY4OutZnH9zI 5slOdFlRsmg57Pgrounygqp2PHip4F4v/3DPqSD5STACggzVJVVg3g+81kkfXGXTG5vQk 721q3yEi265hiRjHJ9tqQV+Ry/byYi+XGfZbeRFIDwgvfglSWIx+KQ8iQhEvPMSM41w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795038688; 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=A7srSwSDwmQ6FJjj76+wtd0cmjT8nvt8dvPacyzCCqs=; b=WW9D3rt8iyUruyGLMwUTyWe4QQnQDZ2qdpZkGeGbKjQNcz0SsQQhDt8Z7oVfH/Hx1kC+ b7+MOqYQL1keNZiQBV6xHwdbW8vzs9F69N//0xSxc8OJ9AKX5LGDOW3T7P/1bdTHRSzXo gtgJjMBtlKsXiRbguHpkYCE8VXrbCYxw2VU9qzR0E2JspDwzdKwdpZXXxkhjuv+1oNZrd 4hKlZf+oNKsUbhQMc92C4GU+gWs7Os398X1IxrPm9HSjBJKsc5uxiX3EPE1bLAt6cDukR kl+85AAyCbb6ysaB59U7saYANxX3GZ4lt82FTSp+csw78y+2BRQi4UhLb+V/+PIRwhA== 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=K6XCoWA0; 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 3D191606A31C; Wed, 18 Nov 2026 21:51:28 +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=K6XCoWA0 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89F6B1F000C4; Wed, 18 Nov 2026 21:51:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795038688; bh=A7srSwSDwmQ6FJjj76+wtd0cmjT8nvt8dvPacyzCCqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=K6XCoWA0I/MHBqj2qo+L+izYHQ9Dz+biNedoWauXLMfhVkbX72Jm8zBKuHFSfpnqx F6b7KiqYNOXnWe4nZhuVsA7DusFV2e7WiN0A31qgj1cnjlYMz/qBPAgYKIiAvmkOOp Q/e6VMl1PBMeqUKpyfhT9Z1cbwJTM7dahl1uQ9Xs= 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 6.6 1790/3318] ASoC: hdac_hda: Allocate the private data at codec driver bind Date: Wed, 18 Nov 2026 15:40:12 +0100 Message-ID: <20261118150415.558613649@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150313.527275416@linuxfoundation.org> References: <20261118150313.527275416@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-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 Omit the dev_index initialization because the private structure has no such member and the firmware patch loader that uses it is absent. Keep the allocation tied to codec driver binding and preserve the existing iDisp audio-component check. 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 | 12 +++++++++++- sound/soc/sof/intel/hda-codec.c | 22 ++++------------------ 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/sound/soc/codecs/hdac_hda.c b/sound/soc/codecs/hdac_hda.c index a3229a51eef33..5a196a756aaf4 100644 --- a/sound/soc/codecs/hdac_hda.c +++ b/sound/soc/codecs/hdac_hda.c @@ -606,10 +606,20 @@ 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); + /* 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 82a6707fb4b80..0bb9e547127ba 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 @@ -139,7 +137,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) | @@ -159,26 +156,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; - 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