mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] platform/x86: Add ACPI_COMPANION() NULL check in topstar_acpi_probe
@ 2026-08-11  2:21 Xueqin Luo
  2026-08-12 18:10 ` Wysocki, Rafael J
  2026-09-15 23:21 ` Ilpo Järvinen
  0 siblings, 2 replies; 3+ messages in thread
From: Xueqin Luo @ 2026-08-11  2:21 UTC (permalink / raw)
  To: herton, hansg, ilpo.jarvinen, rafael.j.wysocki,
	platform-driver-x86, linux-kernel
  Cc: Xueqin Luo

Add NULL check for ACPI_COMPANION() in topstar_acpi_probe() to prevent
NULL pointer dereference when driver_override matches a device without
ACPI companion.

Fixes: 3471415c8186 ("platform/x86: topstar-laptop: Convert ACPI driver to a platform one")
Signed-off-by: Xueqin Luo <luoxueqin@kylinos.cn>
---
 drivers/platform/x86/topstar-laptop.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/topstar-laptop.c b/drivers/platform/x86/topstar-laptop.c
index 0e842c55dcc5..730a599abf0f 100644
--- a/drivers/platform/x86/topstar-laptop.c
+++ b/drivers/platform/x86/topstar-laptop.c
@@ -287,10 +287,14 @@ static const struct dmi_system_id topstar_dmi_ids[] = {
 
 static int topstar_acpi_probe(struct platform_device *pdev)
 {
-	struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
+	struct acpi_device *device;
 	struct topstar_laptop *topstar;
 	int err;
 
+	device = ACPI_COMPANION(&pdev->dev);
+	if (!device)
+		return -ENODEV;
+
 	dmi_check_system(topstar_dmi_ids);
 
 	topstar = kzalloc_obj(struct topstar_laptop);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] platform/x86: Add ACPI_COMPANION() NULL check in topstar_acpi_probe
  2026-08-11  2:21 [PATCH] platform/x86: Add ACPI_COMPANION() NULL check in topstar_acpi_probe Xueqin Luo
@ 2026-08-12 18:10 ` Wysocki, Rafael J
  2026-09-15 23:21 ` Ilpo Järvinen
  1 sibling, 0 replies; 3+ messages in thread
From: Wysocki, Rafael J @ 2026-08-12 18:10 UTC (permalink / raw)
  To: Xueqin Luo, herton, hansg, ilpo.jarvinen, platform-driver-x86,
	linux-kernel, linux-acpi


On 8/11/2026 4:21 AM, Xueqin Luo wrote:
> Add NULL check for ACPI_COMPANION() in topstar_acpi_probe() to prevent
> NULL pointer dereference when driver_override matches a device without
> ACPI companion.
>
> Fixes: 3471415c8186 ("platform/x86: topstar-laptop: Convert ACPI driver to a platform one")
> Signed-off-by: Xueqin Luo <luoxueqin@kylinos.cn>

I'm not sure why I haven't sent a patch to address this, so

Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


> ---
>   drivers/platform/x86/topstar-laptop.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/topstar-laptop.c b/drivers/platform/x86/topstar-laptop.c
> index 0e842c55dcc5..730a599abf0f 100644
> --- a/drivers/platform/x86/topstar-laptop.c
> +++ b/drivers/platform/x86/topstar-laptop.c
> @@ -287,10 +287,14 @@ static const struct dmi_system_id topstar_dmi_ids[] = {
>   
>   static int topstar_acpi_probe(struct platform_device *pdev)
>   {
> -	struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
> +	struct acpi_device *device;
>   	struct topstar_laptop *topstar;
>   	int err;
>   
> +	device = ACPI_COMPANION(&pdev->dev);
> +	if (!device)
> +		return -ENODEV;
> +
>   	dmi_check_system(topstar_dmi_ids);
>   
>   	topstar = kzalloc_obj(struct topstar_laptop);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] platform/x86: Add ACPI_COMPANION() NULL check in topstar_acpi_probe
  2026-08-11  2:21 [PATCH] platform/x86: Add ACPI_COMPANION() NULL check in topstar_acpi_probe Xueqin Luo
  2026-08-12 18:10 ` Wysocki, Rafael J
@ 2026-09-15 23:21 ` Ilpo Järvinen
  1 sibling, 0 replies; 3+ messages in thread
From: Ilpo Järvinen @ 2026-09-15 23:21 UTC (permalink / raw)
  To: herton, hansg, rafael.j.wysocki, platform-driver-x86,
	linux-kernel, Xueqin Luo

On Tue, 11 Aug 2026 10:21:15 +0800, Xueqin Luo wrote:

> Add NULL check for ACPI_COMPANION() in topstar_acpi_probe() to prevent
> NULL pointer dereference when driver_override matches a device without
> ACPI companion.

Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.

FYI [if applicable to your patch], as per Linus' policy change, also
fixes are mostly routed through for-next unless the fix is for a
commit introduced in the most recent cycle or is clearly a regression
fix.

The list of commits applied:
[1/1] platform/x86: Add ACPI_COMPANION() NULL check in topstar_acpi_probe
      commit: 17d0f874b1f8774c61ad495a4ad20ed8c829dfae

--
 i.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-15 23:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-11  2:21 [PATCH] platform/x86: Add ACPI_COMPANION() NULL check in topstar_acpi_probe Xueqin Luo
2026-08-12 18:10 ` Wysocki, Rafael J
2026-09-15 23:21 ` Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®