mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Mika Westerberg" <mika.westerberg@linux.intel.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Hanjun Guo" <guohanjun@huawei.com>,
	"Sudeep Holla" <sudeep.holla@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	linux-efi@vger.kernel.org, "Will Deacon" <will@kernel.org>,
	"Robin Murphy" <robin.murphy@arm.com>,
	"Joerg Roedel (AMD)" <joro@8bytes.org>,
	"Mark Pearson" <mpearson-lenovo@squebb.ca>,
	"Derek J. Clark" <derekjohn.clark@gmail.com>,
	"Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	platform-driver-x86@vger.kernel.org,
	"David Rhodes" <david.rhodes@cirrus.com>,
	"Richard Fitzgerald" <rf@opensource.cirrus.com>,
	"Jaroslav Kysela" <perex@perex.cz>,
	"Takashi Iwai" <tiwai@suse.com>,
	linux-sound@vger.kernel.org,
	"Shenghao Ding" <shenghao-ding@ti.com>,
	"Kevin Lu" <kevin-lu@ti.com>, "Baojun Xu" <baojun.xu@ti.com>,
	"Sen Wang" <sen@ti.com>,
	"Vijendar Mukunda" <Vijendar.Mukunda@amd.com>,
	"Venkata Prasad Potturu" <venkataprasad.potturu@amd.com>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Cezary Rojewski" <cezary.rojewski@intel.com>,
	"Peter Ujfalusi" <peter.ujfalusi@linux.intel.com>,
	"Bard Liao" <yung-chuan.liao@linux.intel.com>,
	"Kai Vehmanen" <kai.vehmanen@linux.intel.com>,
	"Pierre-Louis Bossart" <pierre-louis.bossart@linux.dev>,
	"Binbin Zhou" <zhoubinbin@loongson.cn>,
	"Andreas Noever" <andreas.noever@gmail.com>,
	"Mika Westerberg" <westeri@kernel.org>,
	"Yehezkel Bernat" <YehezkelShB@gmail.com>
Subject: [PATCH v1 15/17] ASoC: intel: boards: Switch to use acpi_bus_get_primary_device()
Date: Mon, 21 Sep 2026 21:55:15 +0200	[thread overview]
Message-ID: <15844908.tv2OnDr8pf@rafael.j.wysocki> (raw)
In-Reply-To: <7995179.EvYhyI6sBW@rafael.j.wysocki>

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

Replace acpi_get_first_physical_node() that is slated for removal
with acpi_bus_get_primary_device() that takes a reference to the
device it is about to return.

This addresses a potential use-after-free that may occur if the
device returned by acpi_get_first_physical_node() is removed right
after dropping its ACPI companion's physical_node_lock in that
function.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 sound/soc/intel/boards/bytcht_es8316.c     | 4 ++--
 sound/soc/intel/boards/bytcr_rt5640.c      | 4 ++--
 sound/soc/intel/boards/bytcr_rt5651.c      | 4 ++--
 sound/soc/intel/boards/cht_bsw_rt5645.c    | 5 ++---
 sound/soc/intel/boards/sof_cirrus_common.c | 2 +-
 sound/soc/intel/boards/sof_es8336.c        | 4 ++--
 6 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c
index ea387dc74273..4d8d1d176a49 100644
--- a/sound/soc/intel/boards/bytcht_es8316.c
+++ b/sound/soc/intel/boards/bytcht_es8316.c
@@ -601,11 +601,11 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	codec_dev = acpi_get_first_physical_node(adev);
+	codec_dev = acpi_bus_get_primary_device(adev);
 	acpi_dev_put(adev);
 	if (!codec_dev)
 		return -EPROBE_DEFER;
-	priv->codec_dev = get_device(codec_dev);
+	priv->codec_dev = codec_dev;
 
 	/* override platform name, if required */
 	byt_cht_es8316_card.dev = dev;
diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
index 40da3eea5fa7..c84b9a0fe65a 100644
--- a/sound/soc/intel/boards/bytcr_rt5640.c
+++ b/sound/soc/intel/boards/bytcr_rt5640.c
@@ -1744,11 +1744,11 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	codec_dev = acpi_get_first_physical_node(adev);
+	codec_dev = acpi_bus_get_primary_device(adev);
 	acpi_dev_put(adev);
 
 	if (codec_dev) {
-		priv->codec_dev = get_device(codec_dev);
+		priv->codec_dev = codec_dev;
 	} else {
 		/*
 		 * Special case for Android tablets where the codec i2c_client
diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c
index 62cb4856c797..a0ed56d285bc 100644
--- a/sound/soc/intel/boards/bytcr_rt5651.c
+++ b/sound/soc/intel/boards/bytcr_rt5651.c
@@ -943,11 +943,11 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	codec_dev = acpi_get_first_physical_node(adev);
+	codec_dev = acpi_bus_get_primary_device(adev);
 	acpi_dev_put(adev);
 	if (!codec_dev)
 		return -EPROBE_DEFER;
-	priv->codec_dev = get_device(codec_dev);
+	priv->codec_dev = codec_dev;
 
 	/*
 	 * swap SSP0 if bytcr is detected
diff --git a/sound/soc/intel/boards/cht_bsw_rt5645.c b/sound/soc/intel/boards/cht_bsw_rt5645.c
index 249be121be15..4f20928a3604 100644
--- a/sound/soc/intel/boards/cht_bsw_rt5645.c
+++ b/sound/soc/intel/boards/cht_bsw_rt5645.c
@@ -529,7 +529,6 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
 	const char *platform_name;
 	struct cht_mc_private *drv;
 	struct acpi_device *adev;
-	struct device *codec_dev;
 	bool sof_parent;
 	bool found = false;
 	bool is_bytcr = false;
@@ -583,8 +582,8 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	/* acpi_get_first_physical_node() returns a borrowed ref, no need to deref */
-	codec_dev = acpi_get_first_physical_node(adev);
+	struct device *codec_dev __free(put_device) = acpi_bus_get_primary_device(adev);
+
 	acpi_dev_put(adev);
 	if (!codec_dev)
 		return -EPROBE_DEFER;
diff --git a/sound/soc/intel/boards/sof_cirrus_common.c b/sound/soc/intel/boards/sof_cirrus_common.c
index 88fc6cb2bfd4..a4ecb1f9a615 100644
--- a/sound/soc/intel/boards/sof_cirrus_common.c
+++ b/sound/soc/intel/boards/sof_cirrus_common.c
@@ -168,7 +168,7 @@ static int cs35l41_compute_codec_conf(void)
 				 cs35l41_name_prefixes[uid]);
 			continue;
 		}
-		physdev = get_device(acpi_get_first_physical_node(adev));
+		physdev = acpi_bus_get_primary_device(adev);
 		acpi_dev_put(adev);
 		if (!physdev) {
 			pr_devel("Cannot find physical node for HID %s UID %u (%s)\n", CS35L41_HID,
diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c
index 9b016136c639..3c0d7155f059 100644
--- a/sound/soc/intel/boards/sof_es8336.c
+++ b/sound/soc/intel/boards/sof_es8336.c
@@ -693,11 +693,11 @@ static int sof_es8336_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	codec_dev = acpi_get_first_physical_node(adev);
+	codec_dev = acpi_bus_get_primary_device(adev);
 	acpi_dev_put(adev);
 	if (!codec_dev)
 		return -EPROBE_DEFER;
-	priv->codec_dev = get_device(codec_dev);
+	priv->codec_dev = codec_dev;
 
 	ret = snd_soc_fixup_dai_links_platform_name(&sof_es8336_card,
 						    mach->mach_params.platform);
-- 
2.51.0





  parent reply	other threads:[~2026-09-21 19:57 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21 19:45 [PATCH v1 00/17] ACPI: Replace acpi_get_first_physical_node() with acpi_bus_get_primary_device() Rafael J. Wysocki
2026-09-21 19:45 ` [PATCH v1 01/17] ACPI: bus: Use acpi/acpi_bus.h without CONFIG_ACPI Rafael J. Wysocki
2026-09-22  9:50   ` Sudeep Holla
2026-09-22  9:51     ` Rafael J. Wysocki (Intel)
2026-09-21 19:46 ` [PATCH v1 02/17] ACPI: amba: Switch to use acpi_bus_get_primary_device() Rafael J. Wysocki
2026-09-22  6:07   ` Hanjun Guo
2026-09-22  9:51   ` Sudeep Holla
2026-09-21 19:47 ` [PATCH v1 03/17] efi/dev-path-parser: " Rafael J. Wysocki
2026-09-21 19:47 ` [PATCH v1 04/17] iommu/arm-smmu-v3: " Rafael J. Wysocki
2026-09-21 19:48 ` [PATCH v1 05/17] platform/x86: yogabook: " Rafael J. Wysocki
2026-09-22 12:50   ` Ilpo Järvinen
2026-09-22 15:31   ` Hans de Goede
2026-09-22 15:34   ` Mark Pearson
2026-09-21 19:49 ` [PATCH v1 06/17] platform/x86: serdev_helpers: " Rafael J. Wysocki
2026-09-22 12:48   ` Ilpo Järvinen
2026-09-22 16:58   ` Hans de Goede
2026-09-21 19:49 ` [PATCH v1 07/17] platform/x86: apple-gmux: " Rafael J. Wysocki
2026-09-22 16:58   ` Hans de Goede
2026-09-21 19:50 ` [PATCH v1 08/17] platform/x86: x86-android-tablets: Use acpi_bus_get_primary_device() Rafael J. Wysocki
2026-09-22 12:46   ` Ilpo Järvinen
2026-09-22 16:59   ` Hans de Goede
2026-09-21 19:51 ` [PATCH v1 09/17] thunderbolt: Switch to use acpi_bus_get_primary_device() Rafael J. Wysocki
2026-09-22 14:30   ` Mika Westerberg
2026-09-21 19:51 ` [PATCH v1 10/17] ALSA: hda: cs35l41: " Rafael J. Wysocki
2026-09-21 19:52 ` [PATCH v1 11/17] ALSA: hda: aw88399: " Rafael J. Wysocki
2026-09-22 12:26   ` Marco Giunta
2026-09-21 19:53 ` [PATCH v1 12/17] ALSA: hda: tas2781: " Rafael J. Wysocki
2026-09-21 19:53 ` [PATCH v1 13/17] ASoC: amd: acp-es8336: " Rafael J. Wysocki
2026-09-22  8:19   ` Mark Brown
2026-09-21 19:54 ` [PATCH v1 14/17] ASoC: amd: acp3x-es83xx: " Rafael J. Wysocki
2026-09-22  8:19   ` Mark Brown
2026-09-21 19:55 ` Rafael J. Wysocki [this message]
2026-09-22  8:02   ` [PATCH v1 15/17] ASoC: intel: boards: " Cezary Rojewski
2026-09-22  8:20   ` Mark Brown
2026-09-21 19:55 ` [PATCH v1 16/17] ASoC: loongson: " Rafael J. Wysocki
2026-09-22  8:20   ` Mark Brown
2026-09-21 19:56 ` [PATCH v1 17/17] ACPI: bus: Drop acpi_get_first_physical_node() Rafael J. Wysocki
2026-09-22  9:53   ` Sudeep Holla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15844908.tv2OnDr8pf@rafael.j.wysocki \
    --to=rafael@kernel.org \
    --cc=Vijendar.Mukunda@amd.com \
    --cc=YehezkelShB@gmail.com \
    --cc=andreas.noever@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=ardb@kernel.org \
    --cc=baojun.xu@ti.com \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@intel.com \
    --cc=david.rhodes@cirrus.com \
    --cc=derekjohn.clark@gmail.com \
    --cc=guohanjun@huawei.com \
    --cc=hansg@kernel.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=joro@8bytes.org \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=kevin-lu@ti.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=mpearson-lenovo@squebb.ca \
    --cc=perex@perex.cz \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rf@opensource.cirrus.com \
    --cc=robin.murphy@arm.com \
    --cc=sen@ti.com \
    --cc=shenghao-ding@ti.com \
    --cc=sudeep.holla@kernel.org \
    --cc=tiwai@suse.com \
    --cc=venkataprasad.potturu@amd.com \
    --cc=westeri@kernel.org \
    --cc=will@kernel.org \
    --cc=yung-chuan.liao@linux.intel.com \
    --cc=zhoubinbin@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®