Re: [PATCH v1 08/17] platform/x86: x86-android-tablets: Use acpi_bus_get_primary_device()
From: Ilpo Järvinen
Date: Tue Sep 22 2026 - 08:48:31 EST
On Mon, 21 Sep 2026, Rafael J. Wysocki wrote:
> From: "Rafael J. Wysocki" <rafael.j.wysocki@xxxxxxxxx>
>
> 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@xxxxxxxxx>
> ---
> drivers/platform/x86/x86-android-tablets/core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/x86-android-tablets/core.c b/drivers/platform/x86/x86-android-tablets/core.c
> index cfff7f5eac5d..2c262f117235 100644
> --- a/drivers/platform/x86/x86-android-tablets/core.c
> +++ b/drivers/platform/x86/x86-android-tablets/core.c
> @@ -390,7 +390,6 @@ static int gpio_secondary_fwnode_init(struct device *parent,
> {
> const struct software_node *const *swnode;
> struct fwnode_handle *fwnode;
> - struct device *phys_dev;
> int ret;
>
> if (!node_group)
> @@ -418,7 +417,8 @@ static int gpio_secondary_fwnode_init(struct device *parent,
> if (WARN_ON(!fwnode))
> return -ENOENT;
>
> - phys_dev = acpi_get_first_physical_node(to_acpi_device(dev));
> + struct device *phys_dev __free(put_device) =
> + acpi_bus_get_primary_device(to_acpi_device(dev));
> if (!phys_dev)
> return dev_err_probe(parent, -ENODEV,
> "No physical device for ACPI GPIO dev: %pfwP\n",
>
Seems to be based on the latest code,
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>
--
i.