The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "Wysocki, Rafael J" <rafael.j.wysocki@intel.com>
Cc: "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>,
	platform-driver-x86@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] platform/x86: asus-wireless: Fail probe when there is no ACPI match
Date: Fri, 10 Jul 2026 12:06:40 +0300 (EEST)	[thread overview]
Message-ID: <f22fda2d-9854-5af5-60c2-489101487e76@linux.intel.com> (raw)
In-Reply-To: <615f444c-494e-66bf-0aaa-6c5b51ef9b8e@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 3128 bytes --]

On Thu, 9 Jul 2026, Ilpo Järvinen wrote:

> On Wed, 8 Jul 2026, Wysocki, Rafael J wrote:
> 
> > On 7/8/2026 3:07 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() returns success when acpi_match_acpi_device()
> > > finds no match, leaving behind an input device that never reports
> > > anything because the notify handler is not installed.  Worse, when the
> > > driver is force-bound to a device without an ACPI companion, probe
> > > still succeeds and stores a NULL companion pointer, which
> > > asus_wireless_remove() later passes to acpi_dev_remove_notify_handler(),
> > > leading to a NULL pointer dereference on unbind.
> > > 
> > > Return -ENODEV when the device does not match the ID table.  This also
> > > covers the missing-companion case, because acpi_match_acpi_device()
> > > rejects a NULL device.
> > > 
> > > Fixes: f7e648027d7e ("platform/x86: asus-wireless: Convert ACPI driver to a
> > > platform one")
> > > Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > > Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
> > 
> > Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > 
> > (no issues found)
> > 
> > > ---
> > > v2: Fail probe when the ACPI ID match fails instead of adding a
> > >      separate ACPI companion check at the top of probe (Rafael).
> > > 
> > >   drivers/platform/x86/asus-wireless.c | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/platform/x86/asus-wireless.c
> > > b/drivers/platform/x86/asus-wireless.c
> > > index 2b494bf3cba8..d33853a1baf3 100644
> > > --- a/drivers/platform/x86/asus-wireless.c
> > > +++ b/drivers/platform/x86/asus-wireless.c
> > > @@ -155,7 +155,7 @@ static int asus_wireless_probe(struct platform_device
> > > *pdev)
> > >     	id = acpi_match_acpi_device(device_ids, adev);
> > >   	if (!id)
> > > -		return 0;
> > > +		return -ENODEV;
> 
> I'm somewhat unsure what the intent here is because the driver is using 
> device_ids as its .acpi_match_table anyway so what's the benefit of doing 
> matching again for the same set of ids?
> 
> Of course having this prevents those overrides but is it really a task for 
> a platform driver to prevent user shooting himself into a foot with that 
> gun (I mean beyond checking NULL like v1 did)?
> 
> I'd tend to think this matching can be removed and the v1 check done 
> instead. But Rafael who undoubtedly knows ACPI much better than I do seems 
> to be in favor of this version?

Nevermind about this, I see now it want to collect ->driver_data...

> I also don't understand why this check is done so late into the probe, 
> IMO, it should simply be done before setting up the input device 
> (logically just before assign adev).

...But I still think it should be done earlier.

-- 
 i.

  reply	other threads:[~2026-07-10  9:06 UTC|newest]

Thread overview: 8+ 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
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
2026-07-10  9:06       ` Ilpo Järvinen [this message]
2026-07-10  9:43         ` [PATCH v3] " Linmao Li
2026-07-10 10:21           ` 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=f22fda2d-9854-5af5-60c2-489101487e76@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=corentin.chary@gmail.com \
    --cc=denis.benato@linux.dev \
    --cc=hansg@kernel.org \
    --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 \
    --cc=rafael.j.wysocki@intel.com \
    /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