All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] platform/x86: wmi: Add Null check for device
@ 2025-03-13 16:28 Chenyuan Yang
  2025-03-14 11:41 ` Ilpo Järvinen
  0 siblings, 1 reply; 5+ messages in thread
From: Chenyuan Yang @ 2025-03-13 16:28 UTC (permalink / raw)
  To: W_Armin, hdegoede, ilpo.jarvinen
  Cc: platform-driver-x86, linux-kernel, Chenyuan Yang

Not all devices have an ACPI companion fwnode, so device might be NULL.
This is similar to the commit cd2fd6eab480
("platform/x86: int3472: Check for adev == NULL").

Add a check for device not being set and return -ENODEV in that case to
avoid a possible NULL pointer deref in parse_wdg().

Note, acpi_wmi_probe() under the same file has such a check.

Signed-off-by: Chenyuan Yang <chenyuan0y@gmail.com>
---
 drivers/platform/x86/wmi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 646370bd6b03..54e697838c1e 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -1091,6 +1091,9 @@ static int parse_wdg(struct device *wmi_bus_dev, struct platform_device *pdev)
 	u32 i, total;
 	int retval;
 
+	if (!device)
+		return -ENODEV;
+
 	status = acpi_evaluate_object(device->handle, "_WDG", NULL, &out);
 	if (ACPI_FAILURE(status))
 		return -ENXIO;
-- 
2.34.1


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

end of thread, other threads:[~2025-03-17 16:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-13 16:28 [PATCH] platform/x86: wmi: Add Null check for device Chenyuan Yang
2025-03-14 11:41 ` Ilpo Järvinen
2025-03-14 16:29   ` Chenyuan Yang
2025-03-15 23:56     ` Armin Wolf
2025-03-17 16:07     ` Ilpo Järvinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.