Skip to content

Commit 7e16932

Browse files
rafaeljwij-intel
authored andcommitted
platform/x86: lg-laptop: Check ACPI_COMPANION() against NULL
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 a requisite ACPI_COMPANION() check against NULL to the platform/x86 lg-laptop driver. Fixes: 2d9cb20 ("platform/x86: lg-laptop: Convert ACPI 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> Link: https://patch.msgid.link/3706551.iIbC2pHGDl@rafael.j.wysocki Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent 922952f commit 7e16932

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

drivers/platform/x86/lg-laptop.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,12 +761,11 @@ static void lg_laptop_remove_address_space_handler(void *data)
761761

762762
static int acpi_probe(struct platform_device *pdev)
763763
{
764-
struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
765764
struct platform_device_info pdev_info = {
766-
.fwnode = acpi_fwnode_handle(device),
767765
.name = PLATFORM_NAME,
768766
.id = PLATFORM_DEVID_NONE,
769767
};
768+
struct acpi_device *device;
770769
acpi_status status;
771770
int ret;
772771
const char *product;
@@ -775,6 +774,12 @@ static int acpi_probe(struct platform_device *pdev)
775774
if (pf_device)
776775
return 0;
777776

777+
device = ACPI_COMPANION(&pdev->dev);
778+
if (!device)
779+
return -ENODEV;
780+
781+
pdev_info.fwnode = acpi_fwnode_handle(device),
782+
778783
status = acpi_install_address_space_handler(device->handle, LG_ADDRESS_SPACE_ID,
779784
&lg_laptop_address_space_handler,
780785
NULL, &pdev->dev);

0 commit comments

Comments
 (0)