Skip to content

Commit f2ec693

Browse files
rafaeljwij-intel
authored andcommitted
platform/x86: sony-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 requisite ACPI_COMPANION() checks against NULL to the platform/x86 sony-laptop driver. Fixes: 138db7e ("platform/x86: sony-laptop: Convert PIC driver to a platform one") Fixes: 14004dd ("platform/x86: sony-laptop: Convert NC 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/1871155.VLH7GnMWUR@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 f15b0a3 commit f2ec693

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

drivers/platform/x86/sony-laptop.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3147,11 +3147,15 @@ static void sony_nc_backlight_cleanup(void)
31473147

31483148
static int sony_nc_probe(struct platform_device *pdev)
31493149
{
3150-
struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
3150+
struct acpi_device *device;
31513151
acpi_status status;
31523152
int result = 0;
31533153
struct sony_nc_value *item;
31543154

3155+
device = ACPI_COMPANION(&pdev->dev);
3156+
if (!device)
3157+
return -ENODEV;
3158+
31553159
sony_nc_acpi_device = device;
31563160
strscpy(acpi_device_class(device), "sony/hotkey");
31573161

@@ -4509,11 +4513,15 @@ static void sony_pic_remove(struct platform_device *pdev)
45094513

45104514
static int sony_pic_probe(struct platform_device *pdev)
45114515
{
4512-
struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
45134516
struct sony_pic_ioport *io, *tmp_io;
45144517
struct sony_pic_irq *irq, *tmp_irq;
4518+
struct acpi_device *device;
45154519
int result;
45164520

4521+
device = ACPI_COMPANION(&pdev->dev);
4522+
if (!device)
4523+
return -ENODEV;
4524+
45174525
spic_dev.acpi_dev = device;
45184526
strscpy(acpi_device_class(device), "sony/hotkey");
45194527
sony_pic_detect_device_type(&spic_dev);

0 commit comments

Comments
 (0)