[PATCH] platform/x86: Add ACPI_COMPANION() NULL check in topstar_acpi_probe
Xueqin Luo <[email protected]>
| Newsgroups | gmane.linux.kernel,gmane.linux.drivers.platform.x86.devel |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]>
---
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