Skip to content

Commit e99829a

Browse files
rafaeljwij-intel
authored andcommitted
platform/x86: fujitsu: 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 requisite ACPI_COMPANION() checks against NULL to the platform/x86 fujitsu-laptop driver. Fixes: 6da22b0 ("platform/x86: fujitsu: Convert laptop driver to a platform one") Fixes: d5c9212 ("platform/x86: fujitsu: Convert backlight 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> Acked-by: Jonathan Woithe <jwoithe@just42.net> Link: https://patch.msgid.link/3430329.44csPzL39Z@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 8148303 commit e99829a

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

drivers/platform/x86/fujitsu-laptop.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,10 +530,14 @@ static void acpi_fujitsu_bl_notify(acpi_handle handle, u32 event, void *data)
530530

531531
static int acpi_fujitsu_bl_probe(struct platform_device *pdev)
532532
{
533-
struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
533+
struct acpi_device *device;
534534
struct fujitsu_bl *priv;
535535
int ret;
536536

537+
device = ACPI_COMPANION(&pdev->dev);
538+
if (!device)
539+
return -ENODEV;
540+
537541
if (acpi_video_get_backlight_type() != acpi_backlight_vendor)
538542
return -ENODEV;
539543

@@ -993,10 +997,14 @@ static void acpi_fujitsu_laptop_notify(acpi_handle handle, u32 event, void *data
993997

994998
static int acpi_fujitsu_laptop_probe(struct platform_device *pdev)
995999
{
996-
struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
9971000
struct fujitsu_laptop *priv;
1001+
struct acpi_device *device;
9981002
int ret, i = 0;
9991003

1004+
device = ACPI_COMPANION(&pdev->dev);
1005+
if (!device)
1006+
return -ENODEV;
1007+
10001008
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
10011009
if (!priv)
10021010
return -ENOMEM;

0 commit comments

Comments
 (0)