linux-stable/drivers/acpi
Andy Shevchenko d74bc74f63 ACPI / device_sysfs: Avoid OF modalias creation for removed device
commit f16eb8a4b0 upstream.

If SSDT overlay is loaded via ConfigFS and then unloaded the device,
we would like to have OF modalias for, already gone. Thus, acpi_get_name()
returns no allocated buffer for such case and kernel crashes afterwards:

 ACPI: Host-directed Dynamic ACPI Table Unload
 ads7950 spi-PRP0001:00: Dropping the link to regulator.0
 BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
 #PF error: [normal kernel read fault]
 PGD 80000000070d6067 P4D 80000000070d6067 PUD 70d0067 PMD 0
 Oops: 0000 [#1] SMP PTI
 CPU: 0 PID: 40 Comm: kworker/u4:2 Not tainted 5.0.0+ #96
 Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 542 2015.01.21:18.19.48
 Workqueue: kacpi_hotplug acpi_device_del_work_fn
 RIP: 0010:create_of_modalias.isra.1+0x4c/0x150
 Code: 00 00 48 89 44 24 18 31 c0 48 8d 54 24 08 48 c7 44 24 10 00 00 00 00 48 c7 44 24 08 ff ff ff ff e8 7a b0 03 00 48 8b 4c 24 10 <0f> b6 01 84 c0 74 27 48 c7 c7 00 09 f4 a5 0f b6 f0 8d 50 20 f6 04
 RSP: 0000:ffffa51040297c10 EFLAGS: 00010246
 RAX: 0000000000001001 RBX: 0000000000000785 RCX: 0000000000000000
 RDX: 0000000000001001 RSI: 0000000000000286 RDI: ffffa2163dc042e0
 RBP: ffffa216062b1196 R08: 0000000000001001 R09: ffffa21639873000
 R10: ffffffffa606761d R11: 0000000000000001 R12: ffffa21639873218
 R13: ffffa2163deb5060 R14: ffffa216063d1010 R15: 0000000000000000
 FS:  0000000000000000(0000) GS:ffffa2163e000000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: 0000000000000000 CR3: 0000000007114000 CR4: 00000000001006f0
 Call Trace:
  __acpi_device_uevent_modalias+0xb0/0x100
  spi_uevent+0xd/0x40

 ...

In order to fix above let create_of_modalias() check the status returned
by acpi_get_name() and bail out in case of failure.

Fixes: 8765c5ba19 ("ACPI / scan: Rework modalias creation when "compatible" is present")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=201381
Reported-by: Ferry Toth <fntoth@gmail.com>
Tested-by: Ferry Toth<fntoth@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: 4.1+ <stable@vger.kernel.org> # 4.1+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-03-23 13:19:46 +01:00
..
acpica ACPICA: acpi: acpica: fix acpi operand cache leak in nseval.c 2018-05-30 07:50:45 +02:00
apei ACPI: APEI / ERST: Fix missing error handling in erst_reader() 2017-12-29 17:42:57 +01:00
arm64 ACPI: Add new IORT functions to support MSI domain handling 2016-09-12 20:32:40 +01:00
dptf ACPI / platform: Add support for build-in properties 2016-11-10 00:30:29 +01:00
nfit acpi/nfit: Fix command-supported detection 2019-01-31 08:12:35 +01:00
pmic ACPI / PMIC: xpower: Fix power_table addresses 2018-03-24 11:00:18 +01:00
ac.c
acpi_amba.c ACPI / amba: Remove CLK_IS_ROOT 2016-04-27 23:42:57 +02:00
acpi_apd.c Merge branch 'device-properties' 2016-11-11 23:23:02 +01:00
acpi_cmos_rtc.c char/genrtc: x86: remove remnants of asm/rtc.h 2016-06-04 00:20:07 +02:00
acpi_configfs.c ACPI: Rename configfs.c to acpi_configfs.c to prevent link error 2016-07-11 15:13:36 +02:00
acpi_dbg.c ACPI / debugger: Fix regression introduced by IS_ERR_VALUE() removal 2016-07-05 23:02:34 +02:00
acpi_extlog.c
acpi_ipmi.c
acpi_lpat.c ACPI / lpat: make it explicitly non-modular 2016-07-16 03:08:10 +02:00
acpi_lpss.c ACPI / LPSS: Add alternative ACPI HIDs for Cherry Trail DMA controllers 2018-11-13 11:16:51 -08:00
acpi_memhotplug.c
acpi_pad.c ACPI: acpi_pad: Fix memory leak in power saving threads 2018-05-30 07:50:43 +02:00
acpi_platform.c ACPI / platform: Add SMB0001 HID to forbidden_id_list 2018-11-27 16:09:41 +01:00
acpi_pnp.c ACPI / PNP: constify device IDs 2016-01-04 22:10:30 +01:00
acpi_processor.c Revert "x86/acpi: Set persistent cpuid <-> nodeid mapping when booting" 2017-12-20 10:07:26 +01:00
acpi_video.c ACPI / video: Only default only_lcd to true on Win8-ready _desktops_ 2018-04-29 11:32:03 +02:00
acpi_watchdog.c ACPI / watchdog: Prefer iTCO_wdt always when WDAT table uses RTC SRAM 2018-11-27 16:09:40 +01:00
battery.c ACPI / battery: Add sysfs representation after checking _BST 2016-08-31 00:35:16 +02:00
battery.h
bgrt.c drivers/acpi: make bgrt driver explicitly non-modular 2016-03-09 23:46:07 +01:00
blacklist.c ACPI / blacklist: Make Dell Latitude 3350 ethernet work 2017-03-22 12:43:38 +01:00
bus.c Revert "x86/acpi: Set persistent cpuid <-> nodeid mapping when booting" 2017-12-20 10:07:26 +01:00
button.c Revert "ACPI / button: Change default behavior to lid_init_state=open" 2017-06-07 12:07:47 +02:00
cm_sbs.c
container.c
cppc_acpi.c ACPI / CPPC: set an error code on probe error path 2017-01-19 20:18:07 +01:00
custom_method.c
debugfs.c
device_pm.c ACPI / PM: Export acpi_device_fix_up_power() 2016-05-20 15:54:01 +02:00
device_sysfs.c ACPI / device_sysfs: Avoid OF modalias creation for removed device 2019-03-23 13:19:46 +01:00
dock.c ACPI / dock: make dock explicitly non-modular 2016-07-16 03:08:08 +02:00
ec.c ACPI: EC: Fix debugfs_create_*() usage 2018-04-13 19:48:10 +02:00
ec_sys.c ACPI: EC: Fix debugfs_create_*() usage 2018-04-13 19:48:10 +02:00
event.c
evged.c ACPI / GED: make evged.c explicitly non-modular 2016-05-09 22:59:25 +02:00
fan.c ACPI / fan: Fix error reading cur_state 2016-10-10 02:20:43 +02:00
glue.c ACPI / scan: Prefer devices without _HID/_CID for _ADR matching 2018-01-31 12:55:52 +01:00
gsi.c ACPI: Rename acpi_gsi_get_irq_type to acpi_dev_get_irq_type and export symbol 2016-01-01 03:20:25 +01:00
hed.c
internal.h ACPI: EC: Fix debugfs_create_*() usage 2018-04-13 19:48:10 +02:00
ioapic.c ACPI: ioapic: Clear on-stack resource before using it 2017-08-30 10:21:55 +02:00
Kconfig TTY/Serial patches for 4.9-rc1 2016-10-03 20:11:49 -07:00
Makefile ACPI: Fix incompatibility with mcount-based function graph tracing 2017-04-08 09:30:34 +02:00
numa.c ACPI: NUMA: Use correct type for printing addresses on i386-PAE 2019-02-20 10:18:28 +01:00
nvs.c
osi.c ACPI / osi: Collect _OSI handling into one single file 2016-05-05 00:13:53 +02:00
osl.c acpi_os_vprintf: Use printk_get_level() to avoid unnecessary KERN_CONT 2016-10-12 21:46:37 +02:00
pci_irq.c ACPI / PCI: fix GIC irq model default PCI IRQ polarity 2016-09-10 02:50:50 +02:00
pci_link.c ACPI/PCI: pci_link: Include PIRQ_PENALTY_PCI_USING for ISA IRQs 2016-10-24 14:18:14 +02:00
pci_mcfg.c PCI/ACPI: Add generic MCFG table handling 2016-06-10 18:27:59 -05:00
pci_root.c PCI: pciehp: Request control of native hotplug only if supported 2018-08-03 07:55:19 +02:00
pci_slot.c ACPI / PCI: make pci_slot explicitly non-modular 2016-07-16 03:05:29 +02:00
power.c ACPI: power: Skip duplicate power resource references in _PRx 2019-01-16 22:12:32 +01:00
proc.c ACPI: change acpi_sleep_proc_init() to return void 2015-09-15 03:03:15 +02:00
processor_core.c Revert "x86/acpi: Set persistent cpuid <-> nodeid mapping when booting" 2017-12-20 10:07:26 +01:00
processor_driver.c ACPI/processor: Replace racy task affinity logic 2018-03-24 11:00:09 +01:00
processor_idle.c nmi_backtrace: generate one-line reports for idle cpus 2016-10-07 18:46:30 -07:00
processor_pdc.c
processor_perflib.c ACPI: processor_perflib: Do not send _PPC change notification if not ready 2018-05-30 07:50:24 +02:00
processor_thermal.c
processor_throttling.c ACPI/processor: Replace racy task affinity logic 2018-03-24 11:00:09 +01:00
property.c ACPI / property: Allow holes in reference properties 2016-10-11 22:44:00 +02:00
reboot.c
resource.c PCI: ACPI: IA64: fix IO port generic range check 2016-03-22 23:07:49 +01:00
sbs.c ACPI / SBS: fix inconsistent indenting inside if statement 2016-01-04 22:14:27 +01:00
sbshc.c ACPI: sbshc: remove raw pointer from printk() message 2018-02-17 13:21:20 +01:00
sbshc.h
scan.c ACPI / scan: Initialize status to ACPI_STA_DEFAULT 2018-09-15 09:42:59 +02:00
sleep.c ACPI / PM: save NVS memory for ASUS 1025C laptop 2018-08-22 07:47:15 +02:00
sleep.h ACPI / power: Delay turning off unused power resources after suspend 2018-03-24 11:00:20 +01:00
spcr.c ACPI: parse SPCR and enable matching console 2016-09-28 17:46:46 +02:00
sysfs.c ACPI: sysfs: Make ACPI GPE mask kernel parameter cover all GPEs 2018-11-10 07:42:45 -08:00
tables.c ACPI / tables: Remove duplicated include from tables.c 2016-09-17 01:03:32 +02:00
thermal.c thermal: Enhance thermal_zone_device_update for events 2016-09-27 14:35:21 +08:00
utils.c nfit: make DIMM DSMs optional 2016-07-19 12:32:39 -07:00
video_detect.c ACPI / video: Add quirk to force acpi-video backlight on Samsung 670Z5E 2018-04-24 09:34:10 +02:00
wakeup.c