Linux ACPI
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: "Hans de Goede" <hansg@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Linux ACPI" <linux-acpi@vger.kernel.org>,
	"Corentin Chary" <corentin.chary@gmail.com>,
	"Luke D. Jones" <luke@ljones.dev>,
	"Denis Benato" <denis.benato@linux.dev>,
	"Pali Rohár" <pali@kernel.org>,
	"Jonathan Woithe" <jwoithe@just42.net>,
	"Robert Gerlach" <khnz@gmx.de>,
	"Matan Ziv-Av" <matan@svgalib.org>,
	"Kenneth Chan" <kenneth.t.chan@gmail.com>,
	"Mattia Dongili" <malattia@linux.it>,
	"Jeremy Soller" <jeremy@system76.com>,
	"Azael Avalos" <coproscefalo@gmail.com>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	platform-driver-x86@vger.kernel.org
Subject: [PATCH v2 11/16] platform/x86: sony-laptop: Check ACPI_COMPANION() against NULL
Date: Tue, 12 May 2026 16:13:59 +0200	[thread overview]
Message-ID: <1871155.VLH7GnMWUR@rafael.j.wysocki> (raw)
In-Reply-To: <12904885.O9o76ZdvQC@rafael.j.wysocki>

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

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.

Accordingly, add requisite ACPI_COMPANION() checks against NULL to the
platform/x86 sony-laptop driver.

Fixes: 138db7ee58c0 ("platform/x86: sony-laptop: Convert PIC driver to a platform one")
Fixes: 14004dd31caa ("platform/x86: sony-laptop: Convert NC driver to a platform one")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/platform/x86/sony-laptop.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index b18f00e9082f..67370967df6f 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -3147,11 +3147,15 @@ static void sony_nc_backlight_cleanup(void)
 
 static int sony_nc_probe(struct platform_device *pdev)
 {
-	struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
+	struct acpi_device *device;
 	acpi_status status;
 	int result = 0;
 	struct sony_nc_value *item;
 
+	device = ACPI_COMPANION(&pdev->dev);
+	if (!device)
+		return -ENODEV;
+
 	sony_nc_acpi_device = device;
 	strscpy(acpi_device_class(device), "sony/hotkey");
 
@@ -4509,11 +4513,15 @@ static void sony_pic_remove(struct platform_device *pdev)
 
 static int sony_pic_probe(struct platform_device *pdev)
 {
-	struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
 	struct sony_pic_ioport *io, *tmp_io;
 	struct sony_pic_irq *irq, *tmp_irq;
+	struct acpi_device *device;
 	int result;
 
+	device = ACPI_COMPANION(&pdev->dev);
+	if (!device)
+		return -ENODEV;
+
 	spic_dev.acpi_dev = device;
 	strscpy(acpi_device_class(device), "sony/hotkey");
 	sony_pic_detect_device_type(&spic_dev);
-- 
2.51.0





  parent reply	other threads:[~2026-05-12 14:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 14:01 [PATCH v2 00/16] platform/x86: Check ACPI_COMPANION() against NULL during probe Rafael J. Wysocki
2026-05-12 14:03 ` [PATCH v2 01/16] platform/x86: acer-wireless: Check ACPI_COMPANION() against NULL Rafael J. Wysocki
2026-05-12 14:04 ` [PATCH v2 02/16] platform/x86: asus-laptop: " Rafael J. Wysocki
2026-05-12 14:05 ` [PATCH v2 03/16] platform/x86: dell/dell-rbtn: " Rafael J. Wysocki
2026-05-12 14:05 ` [PATCH v2 04/16] platform/x86: eeepc-laptop: " Rafael J. Wysocki
2026-05-12 14:08 ` [PATCH v2 05/16] platform/x86: fujitsu: " Rafael J. Wysocki
2026-05-12 14:09 ` [PATCH v2 06/16] platform/x86: fujitsu-tablet: " Rafael J. Wysocki
2026-05-12 14:11 ` [PATCH v2 07/16] platform/x86: intel/rst: " Rafael J. Wysocki
2026-05-12 14:11 ` [PATCH v2 08/16] platform/x86: intel/smartconnect: Check ACPI_HANDLE() " Rafael J. Wysocki
2026-05-12 14:12 ` [PATCH v2 09/16] platform/x86: lg-laptop: Check ACPI_COMPANION() " Rafael J. Wysocki
2026-05-12 14:13 ` [PATCH v2 10/16] platform/x86: panasonic-laptop: " Rafael J. Wysocki
2026-05-12 14:13 ` Rafael J. Wysocki [this message]
2026-05-12 14:14 ` [PATCH v2 12/16] platform/x86: system76: " Rafael J. Wysocki
2026-05-12 14:15 ` [PATCH v2 13/16] platform/x86: toshiba_acpi: " Rafael J. Wysocki
2026-05-12 14:16 ` [PATCH v2 14/16] platform/x86: toshiba_bluetooth: " Rafael J. Wysocki
2026-05-12 14:17 ` [PATCH v2 15/16] platform/x86: toshiba_haps: " Rafael J. Wysocki
2026-05-12 14:17 ` [PATCH v2 16/16] platform/x86: wireless-hotkey: " Rafael J. Wysocki

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=1871155.VLH7GnMWUR@rafael.j.wysocki \
    --to=rafael@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=coproscefalo@gmail.com \
    --cc=corentin.chary@gmail.com \
    --cc=denis.benato@linux.dev \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jeremy@system76.com \
    --cc=jwoithe@just42.net \
    --cc=kenneth.t.chan@gmail.com \
    --cc=khnz@gmx.de \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luke@ljones.dev \
    --cc=malattia@linux.it \
    --cc=matan@svgalib.org \
    --cc=pali@kernel.org \
    --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