linux/drivers/acpi
Rafael J. Wysocki 6ff054cc02 ACPI: NFIT: core: Fix acpi_nfit_init() error cleanup
[ Upstream commit 38bf27511e ]

If acpi_nfit_init() fails after adding the acpi_desc object to the
acpi_descs list, that object is never removed from that list because
the acpi_nfit_shutdown() devm action is not added for the NFIT device
in that case.  Next, the acpi_nfit_init() failure causes
acpi_nfit_probe() to fail, the acpi_desc object is freed, and a
dangling pointer is left behind in the acpi_descs.  Any subsequent
ACPI Machine Check Exception will trigger nfit_handle_mce() which
iterates over acpi_descs and so a use-after-free will occur.

Moreover, if acpi_nfit_probe() returns 0 after installing a notify
handler for the NFIT device and without allocating the acpi_desc
object and setting the NFIT device's driver data pointer, the
acpi_desc object will be allocated by acpi_nfit_update_notify()
and acpi_nfit_init() will be called to initialize it.  Regardless
of whether or not acpi_nfit_init() fails in that case, the
acpi_nfit_shutdown() devm action is not added for the NFIT device
and acpi_desc is never removed from the acpi_descs list.  If the
acpi_desc object is freed subsequently on driver removal, any
subsequent ACPI MCE will lead to a use-after-free like in the
previous case.

To address the first issue mentioned above, make acpi_nfit_probe()
call acpi_nfit_shutdown() directly on acpi_nfit_init() failures and
to address the other one, add a remove callback to the driver and
make it call acpi_nfit_shutdown().  Also, since it is now possible to
pass NULL to acpi_nfit_shutdown() or the acpi_desc object passed to it
may not have been initialized, add checks against NULL for acpi_desc and
its nvdimm_bus field to that function and make acpi_nfit_unregister()
clear the latter after unregistering the NVDIMM bus.

Fixes: a61fe6f790 ("nfit, tools/testing/nvdimm: unify common init for acpi_nfit_desc")
Fixes: fbabd829fe ("acpi, nfit: fix module unload vs workqueue shutdown race")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: All applicable <stable@vger.kernel.org>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://patch.msgid.link/1963615.tdWV9SEqCh@rafael.j.wysocki
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-07-24 15:51:56 +02:00
..
acpica ACPICA: Allow address_space_handler Install and _REG execution as 2 separate steps 2026-04-18 10:33:26 +02:00
apei APEI/GHES: ensure that won't go past CPER allocated record 2026-03-04 07:19:58 -05:00
arm64 acpi/arm64: Adjust error handling procedure in gtdt_parse_timer_block() 2024-12-14 19:50:43 +01:00
dptf ACPI: DPTF: Add new PCH FIVR methods 2021-08-04 18:08:50 +02:00
nfit ACPI: NFIT: core: Fix acpi_nfit_init() error cleanup 2026-07-24 15:51:56 +02:00
numa acpi,srat: Fix incorrect device handle check for Generic Initiator 2025-12-07 06:09:28 +09:00
pmic ACPI: PMIC: Remove unneeded check in tps68470_pmic_opregion_probe() 2024-10-17 15:10:43 +02:00
x86 ACPI: x86: Force StorageD3Enable on more products 2024-07-05 09:14:39 +02:00
ac.c ACPI: AC: Quirk GK45 to skip reading _PSR 2021-11-18 19:16:19 +01:00
acpi_adxl.c ACPI/ADXL: Add address translation interface using an ACPI DSM 2018-10-16 10:03:00 +02:00
acpi_amba.c ACPI: AMBA: Fix resource name in /proc/iomem 2021-06-30 20:01:10 +02:00
acpi_apd.c serial: 8250_dw: Add device HID for new AMD UART controller 2021-05-13 17:08:42 +02:00
acpi_cmos_rtc.c ACPI: cmos_rtc: Using pr_fmt() and remove PREFIX 2021-06-07 15:36:45 +02:00
acpi_configfs.c ACPI: configfs: Make get_header() to return error pointer 2021-07-16 19:20:28 +02:00
acpi_dbg.c ACPI: debug: fix signedness issues in read/write helpers 2025-10-19 16:21:43 +02:00
acpi_extlog.c ACPI: extlog: fix NULL pointer dereference check 2024-02-23 08:54:38 +01:00
acpi_fpdt.c ACPI: FPDT: properly handle invalid FPDT subtables 2023-11-28 16:56:29 +00:00
acpi_ipmi.c ACPI: IPMI: Fix message kref handling on dead device 2026-07-24 15:51:33 +02:00
acpi_lpat.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174 2019-05-30 11:26:41 -07:00
acpi_lpit.c ACPI: LPIT: Avoid u32 multiplication overflow 2024-01-25 14:52:33 -08:00
acpi_lpss.c ACPI: LPSS: Fix the fractional clock divider flags 2024-01-25 14:52:34 -08:00
acpi_memhotplug.c ACPI: memhotplug: use a single static memory group for a single memory device 2021-09-08 11:50:23 -07:00
acpi_pad.c ACPI: PAD: fix crash in exit_round_robin() 2024-10-17 15:11:24 +02:00
acpi_platform.c ACPI: platform: Remove ACPI_MODULE_NAME() 2020-09-25 18:25:51 +02:00
acpi_pnp.c ACPI: PNP: compare the string length in the matching_id() 2020-12-15 19:30:49 +01:00
acpi_processor.c ACPI: processor: Fix previous acpi_processor_errata_piix4() fix 2026-04-18 10:33:21 +02:00
acpi_tad.c ACPI: TAD: Add missing sysfs_remove_group() for ACPI_TAD_RT 2025-10-19 16:21:43 +02:00
acpi_video.c ACPI: video: Fix use-after-free in acpi_video_switch_brightness() 2025-12-07 06:09:13 +09:00
acpi_watchdog.c ACPI: watchdog: Replace open coded variant of resource_union() 2020-11-17 18:06:29 +01:00
battery.c Revert "ACPI: battery: negate current when discharging" 2025-07-17 18:30:50 +02:00
bgrt.c ACPI: bgrt: Use sysfs_emit 2021-06-23 19:27:50 +02:00
blacklist.c ACPI: blacklist: Unify the message printing 2021-06-07 15:36:45 +02:00
bus.c ACPI: bus: Bail out if acpi_kobj registration fails 2025-06-27 11:05:28 +01:00
button.c ACPI: button: Add DMI quirk for Samsung Galaxy Book2 to fix initial lid detection issue 2024-11-01 01:52:37 +01:00
container.c ACPI: container: Remove leftover ACPICA debug functionality 2020-09-25 18:25:51 +02:00
cppc_acpi.c ACPI: CPPC: Suppress UBSAN warning caused by field misuse 2026-07-24 15:51:56 +02:00
custom_method.c ACPI: custom_method: fix a possible memory leak 2021-04-28 19:17:54 +02:00
debugfs.c ACPI: debugfs: Remove dead ACPICA debug code 2020-09-25 18:25:51 +02:00
device_pm.c for-5.14/drivers-2021-06-29 2021-06-30 12:21:16 -07:00
device_sysfs.c ACPI: sysfs: validate return type of _STR method 2024-10-17 15:11:13 +02:00
dock.c ACPI: dock: fix some coding style issues 2021-04-08 16:27:03 +02:00
ec.c ACPI: EC: Fix ECDT probe ordering issues 2026-04-18 10:33:26 +02:00
ec_sys.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 482 2019-06-19 17:09:52 +02:00
event.c Merge branches 'acpi-ec', 'acpi-apei', 'acpi-soc' and 'acpi-misc' 2021-06-29 15:51:25 +02:00
evged.c ACPI: GED: fix -Wformat 2020-11-09 19:25:20 +01:00
fan.c ACPI: fan: cleanup resources in the error path of .probe() 2025-03-13 12:49:56 +01:00
fan.h ACPI: PM / fan: Put fan device IDs into separate header file 2021-05-21 19:02:35 +02:00
glue.c Revert "ACPI: scan: Release PM resources blocked by unused objects" 2021-11-21 13:44:14 +01:00
hed.c ACPI: HED: Always initialize before evged 2025-06-04 14:38:01 +02:00
internal.h ACPI: EC: Fix EC address space handler unregistration 2026-04-18 10:33:26 +02:00
ioapic.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
irq.c ACPI: irq: Fix incorrect return value in acpi_register_gsi() 2023-10-25 11:59:02 +02:00
Kconfig ACPI: HED: Always initialize before evged 2025-06-04 14:38:01 +02:00
Makefile IOMMU Updates for Linux v5.14 2021-07-02 13:22:47 -07:00
nvs.c Merge branches 'acpi-ec', 'acpi-apei', 'acpi-soc' and 'acpi-misc' 2021-06-29 15:51:25 +02:00
osi.c ACPI: OSI: Add DMI quirk for Acer Aspire One D255 2026-04-18 10:33:11 +02:00
osl.c ACPI: OSL: fix __iomem type on return from acpi_os_map_generic_address() 2026-04-18 10:33:13 +02:00
pci_irq.c ACPI: PCI: IRQ: Consolidate printing diagnostic messages 2021-03-08 16:51:08 +01:00
pci_link.c ACPI: utils: Introduce acpi_evaluation_failure_warn() 2021-03-08 19:10:30 +01:00
pci_mcfg.c PCI/ACPI: Guard ARM64-specific mcfg_quirks 2022-08-25 11:40:36 +02:00
pci_root.c ACPI: APEI: explicit init of HEST and GHES in apci_init() 2022-08-17 14:23:11 +02:00
pci_slot.c ACPI: PCI: Remove unused ACPICA debug code 2020-09-25 18:25:51 +02:00
platform_profile.c ACPI: platform-profile: Fix CFI violation when accessing sysfs files 2025-05-02 07:44:06 +02:00
power.c ACPI: scan: Use acpi_dev_put() in object add error paths 2026-06-01 17:35:19 +02:00
pptt.c ACPI: PPTT: Fix processor subtable walk 2025-05-22 14:08:25 +02:00
prmt.c ACPI: PRM: Skip handlers with NULL handler_address or NULL VA 2025-12-07 06:09:16 +09:00
proc.c ACPI: proc: Remove dead ACPICA debug code 2020-09-25 18:25:51 +02:00
processor_core.c ACPI: processor_core: fix map_x2apic_id for amd-pstate on am4 2026-01-19 13:09:34 +01:00
processor_driver.c ACPI: processor: Get rid of ACPICA message printing 2021-03-08 16:51:19 +01:00
processor_idle.c ACPI: processor: idle: Fix memory leak when register cpuidle device failed 2025-10-19 16:21:29 +02:00
processor_pdc.c ACPI: processor: Fix evaluating _PDC method when running as Xen dom0 2023-05-11 23:00:22 +09:00
processor_perflib.c ACPI: processor: perflib: Move problematic pr->performance check 2025-08-28 16:24:15 +02:00
processor_thermal.c ACPI: processor: Remove freq Qos request for all CPUs 2022-08-31 17:16:48 +02:00
processor_throttling.c Merge branches 'acpi-dptf' and 'acpi-messages' 2021-06-29 15:50:37 +02:00
property.c ACPI: property: Use ACPI functions in acpi_graph_get_next_endpoint() only 2026-01-19 13:09:41 +01:00
reboot.c ACPI: reboot: Unify the message printing 2021-06-07 15:36:46 +02:00
resource.c ACPI: resource: Amend kernel-doc style 2026-07-24 15:51:39 +02:00
sbs.c ACPI: SBS: manage alarm sysfs attribute through psy core 2024-08-19 05:45:37 +02:00
sbshc.c Merge branches 'acpi-ec', 'acpi-apei', 'acpi-soc' and 'acpi-misc' 2021-06-29 15:51:25 +02:00
sbshc.h ACPI: Fix whitespace inconsistencies 2020-11-09 19:08:06 +01:00
scan.c ACPI: scan: Use acpi_dev_put() in object add error paths 2026-06-01 17:35:19 +02:00
sleep.c ACPI: PM: Save NVS memory on Lenovo G70-35 2026-04-18 10:33:11 +02:00
sleep.h Revert "Revert "ACPI: scan: Turn off unused power resources during initialization"" 2021-05-10 14:02:17 +02:00
spcr.c ACPI: SPCR: Add support for the new 16550-compatible Serial Port Subtype 2021-08-16 18:38:08 +02:00
sysfs.c ACPI: sysfs: Fix BERT error region memory mapping 2022-05-30 09:28:58 +02:00
tables.c memblock: exclude MEMBLOCK_NOMAP regions from kmemleak 2021-10-21 18:30:49 -10:00
thermal.c ACPI: thermal: Drop nocrt parameter 2023-09-02 09:17:07 +02:00
tiny-power-button.c ACPI: tiny-power-button: Simplify the code using module_acpi_driver() 2020-11-17 18:12:34 +01:00
utils.c ACPI: utils: Fix reference counting in for_each_acpi_dev_match() 2021-07-19 16:22:01 +02:00
video_detect.c ACPI: video: force native backlight on HP OMEN 16 (8A44) 2026-06-01 17:35:19 +02:00
viot.c ACPI: VIOT: Initialize the correct IOMMU fwspec 2023-05-11 23:00:23 +09:00
wakeup.c ACPI: Fix whitespace inconsistencies 2020-11-09 19:08:06 +01:00