From: "Wysocki, Rafael J" <rafael.j.wysocki@intel.com>
To: "Linmao Li" <lilinmao@kylinos.cn>,
"Corentin Chary" <corentin.chary@gmail.com>,
"Luke D. Jones" <luke@ljones.dev>,
"Denis Benato" <denis.benato@linux.dev>,
"João Paulo Rechi Vita" <jprvita@gmail.com>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: <platform-driver-x86@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] platform/x86: asus-wireless: Check ACPI_COMPANION() against NULL
Date: Mon, 6 Jul 2026 19:29:48 +0200 [thread overview]
Message-ID: <971fe9bd-0c58-47eb-9a35-df085654df34@intel.com> (raw)
In-Reply-To: <20260706024953.534671-1-lilinmao@kylinos.cn>
On 7/6/2026 4:49 AM, Linmao Li wrote:
> Every platform driver can be forced to match a device that doesn't match
> its list of device IDs because of device_match_driver_override(), so
> platform drivers that rely on the existence of a device's ACPI companion
> object need to verify its presence.
>
> asus_wireless_probe() stores the result of ACPI_COMPANION() without
> checking it and still succeeds when it is NULL, because
> acpi_match_acpi_device() handles a NULL device gracefully. Unbinding
> the driver afterwards leads to a NULL pointer dereference when
> asus_wireless_remove() passes the stored NULL pointer to
> acpi_dev_remove_notify_handler(), which dereferences it.
>
> Accordingly, add a requisite ACPI_COMPANION() check against NULL to the
> platform/x86 asus-wireless driver.
>
> Fixes: f7e648027d7e ("platform/x86: asus-wireless: Convert ACPI driver to a platform one")
> Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
> ---
> drivers/platform/x86/asus-wireless.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/asus-wireless.c b/drivers/platform/x86/asus-wireless.c
> index 2b494bf3cba8..2a43d76a5d19 100644
> --- a/drivers/platform/x86/asus-wireless.c
> +++ b/drivers/platform/x86/asus-wireless.c
> @@ -127,11 +127,15 @@ static void asus_wireless_notify(acpi_handle handle, u32 event, void *context)
>
> static int asus_wireless_probe(struct platform_device *pdev)
> {
> - struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
> struct asus_wireless_data *data;
> const struct acpi_device_id *id;
> + struct acpi_device *adev;
> int err;
>
> + adev = ACPI_COMPANION(&pdev->dev);
> + if (!adev)
> + return -ENODEV;
> +
> data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
> if (!data)
> return -ENOMEM;
I'd rather make it return an error when the acpi_match_acpi_device()
call below fails. It is not very useful to return success from probe if
the driver is not going to handle the device IMV.
next prev parent reply other threads:[~2026-07-06 17:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 2:49 [PATCH] platform/x86: asus-wireless: Check ACPI_COMPANION() against NULL Linmao Li
2026-07-06 17:29 ` Wysocki, Rafael J [this message]
2026-07-08 1:07 ` [PATCH v2] platform/x86: asus-wireless: Fail probe when there is no ACPI match Linmao Li
2026-07-08 13:41 ` Wysocki, Rafael J
2026-07-09 10:53 ` Ilpo Järvinen
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=971fe9bd-0c58-47eb-9a35-df085654df34@intel.com \
--to=rafael.j.wysocki@intel.com \
--cc=corentin.chary@gmail.com \
--cc=denis.benato@linux.dev \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jprvita@gmail.com \
--cc=lilinmao@kylinos.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=luke@ljones.dev \
--cc=platform-driver-x86@vger.kernel.org \
/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