Linux CXL
 help / color / mirror / Atom feed
* [PATCH] cxl/acpi: Add Null check for adev
@ 2025-03-13 19:07 Chenyuan Yang
  2025-03-13 22:04 ` Alison Schofield
  2025-03-13 22:31 ` Dan Williams
  0 siblings, 2 replies; 4+ messages in thread
From: Chenyuan Yang @ 2025-03-13 19:07 UTC (permalink / raw)
  To: dave, jonathan.cameron, dave.jiang, alison.schofield,
	vishal.l.verma, ira.weiny, dan.j.williams
  Cc: linux-cxl, linux-kernel, Chenyuan Yang

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

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

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

diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c
index cb14829bb9be..9195001db3c1 100644
--- a/drivers/cxl/acpi.c
+++ b/drivers/cxl/acpi.c
@@ -823,6 +823,9 @@ static int cxl_acpi_probe(struct platform_device *pdev)
 	struct acpi_device *adev = ACPI_COMPANION(host);
 	struct cxl_cfmws_context ctx;
 
+	if (!adev)
+		return -ENODEV;
+
 	device_lock_set_class(&pdev->dev, &cxl_root_key);
 	rc = devm_add_action_or_reset(&pdev->dev, cxl_acpi_lock_reset_class,
 				      &pdev->dev);
-- 
2.34.1


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

end of thread, other threads:[~2025-03-13 22:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-13 19:07 [PATCH] cxl/acpi: Add Null check for adev Chenyuan Yang
2025-03-13 22:04 ` Alison Schofield
2025-03-13 22:27   ` Dave Jiang
2025-03-13 22:31 ` Dan Williams

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