From nobody Sun Jul 26 01:48:33 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24B283F076D; Fri, 10 Jul 2026 09:44:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783676652; cv=none; b=TKZU9fR1tu3JEUL2n6dWWLfA0LRwhwRgREMmh+XD/mnbx2/BvSJXG8Hk1DdWskwsOMCJBTB3pkItqBk+Q+nU3F0m+2EPVTRuZUJF7Y8rqAsWhDbZWBL4Md0gmm76E+t18WWE28nvh3sv8nKlNfkGIONo8PSF0F7hrTuryqfORWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783676652; c=relaxed/simple; bh=EUiqwnMm2Hkqp98PGZKY0VirWkzbbRrCbsEtAT2YOHw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TlF8T2fjkcFJBOKymVQwefzdhESnMYPrmiqJSOfs4+i+tKjp9mpnrmglnwpeEf1uNy3RGInyhjynLBG86id+PmvPM3gBfVW/L5LTsf/3NMhdSP2sKiiHLEQBTMD6hbw8pOYWJ2yePgss5BLfUI2hL19vkMfn7v/mOeZBvWh09Ms= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: e0c91e7a7c4311f1aa26b74ffac11d73-20260710 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:2cbe53f7-ceaf-447b-95ba-1d8b4e2f0060,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:e7bac3a,CLOUDID:7b7a5e538aa6ea757daee86518abbacd,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|850|865|898,TC:nil,Content:0|1 5|50,EDM:-3,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI :0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: e0c91e7a7c4311f1aa26b74ffac11d73-20260710 X-User: lilinmao@kylinos.cn Received: from localhost.localdomain [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 1105298177; Fri, 10 Jul 2026 17:44:00 +0800 From: Linmao Li To: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , "Rafael J . Wysocki" Cc: Corentin Chary , "Luke D . Jones" , Denis Benato , =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= , Hans de Goede , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Linmao Li Subject: [PATCH v3] platform/x86: asus-wireless: Fail probe when there is no ACPI match Date: Fri, 10 Jul 2026 17:43:55 +0800 Message-Id: <20260710094355.186143-1-lilinmao@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Every platform driver can be forced to match a device that does not match its list of device IDs because of device_match_driver_override(), so platform drivers that rely on the existence of a device 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. Perform the check before allocating any driver state, instead of after the input device has already been registered. Fixes: f7e648027d7e ("platform/x86: asus-wireless: Convert ACPI driver to a= platform one") Suggested-by: Rafael J. Wysocki Signed-off-by: Linmao Li --- v3: Move the ACPI ID match before allocating driver state, instead of after the input device has already been registered (Ilpo). 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 | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/asus-wireless.c b/drivers/platform/x86/as= us-wireless.c index 2b494bf3cba8..aab45f0442c5 100644 --- a/drivers/platform/x86/asus-wireless.c +++ b/drivers/platform/x86/asus-wireless.c @@ -132,6 +132,10 @@ static int asus_wireless_probe(struct platform_device = *pdev) const struct acpi_device_id *id; int err; =20 + id =3D acpi_match_acpi_device(device_ids, adev); + if (!id) + return -ENODEV; + data =3D devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; @@ -139,6 +143,7 @@ static int asus_wireless_probe(struct platform_device *= pdev) platform_set_drvdata(pdev, data); =20 data->adev =3D adev; + data->hswc_params =3D (const struct hswc_params *)id->driver_data; =20 data->idev =3D devm_input_allocate_device(&pdev->dev); if (!data->idev) @@ -153,12 +158,6 @@ static int asus_wireless_probe(struct platform_device = *pdev) if (err) return err; =20 - id =3D acpi_match_acpi_device(device_ids, adev); - if (!id) - return 0; - - data->hswc_params =3D (const struct hswc_params *)id->driver_data; - data->wq =3D create_singlethread_workqueue("asus_wireless_workqueue"); if (!data->wq) return -ENOMEM; --=20 2.25.1