Skip to contentSkip to conversation

Patch "acpi/nfit: Fix memory corruption/Unregister mce decoder on failure" has been added to the 4.12-stable tree

PATCH [email protected] 1 participant 1 message Jul 25, 2017

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

acpi/nfit: Fix memory corruption/Unregister mce decoder on failure

to the 4.12-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
acpi-nfit-fix-memory-corruption-unregister-mce-decoder-on-failure.patch
and it can be found in the queue-4.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 7e700d2c59e5853c9126642976b4f5768f64c9b3 Mon Sep 17 00:00:00 2001

From: Prarit Bhargava <[email protected]>
Date: Wed, 31 May 2017 13:32:00 -0400
Subject: acpi/nfit: Fix memory corruption/Unregister mce decoder on failure

From: Prarit Bhargava <[email protected]>

commit 7e700d2c59e5853c9126642976b4f5768f64c9b3 upstream.

nfit_init() calls nfit_mce_register() on module load. When the module load fails the nfit mce decoder is not unregistered. The module's memory is freed leaving the decoder chain referencing junk. This will cause panics as future registrations will reference the free'd memory.

Unregister the nfit mce decoder on module init failure.

[v2]: register and then unregister mce handler to avoid losing mce events [v3]: also cleanup nfit workqueue

Fixes 6839a6d96f4e ("nfit: do an ARS scrub on hitting a latent media error")
Cc "Rafael J. Wysocki" <[email protected]>
Cc Len Brown <[email protected]>
Cc Vishal Verma <[email protected]>
Cc "Lee, Chun-Yi" <[email protected]>
Cc Linda Knippers <[email protected]>
---
 drivers/acpi/nfit/core.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/acpi/nfit/core.c +9 -1
@@ -3043,6 +3043,8 @@ static struct acpi_driver acpi_nfit_driv
 
 static __init int nfit_init(void)
 {
+	int ret;
+
 	BUILD_BUG_ON(sizeof(struct acpi_table_nfit) != 40);
 	BUILD_BUG_ON(sizeof(struct acpi_nfit_system_address) != 56);
 	BUILD_BUG_ON(sizeof(struct acpi_nfit_memory_map) != 48);
@@ -3070,8 +3072,14 @@ static __init int nfit_init(void)
 		return -ENOMEM;
 
 	nfit_mce_register();
+	ret = acpi_bus_register_driver(&acpi_nfit_driver);
+	if (ret) {
+		nfit_mce_unregister();
+		destroy_workqueue(nfit_wq);
+	}
+
+	return ret;
 
-	return acpi_bus_register_driver(&acpi_nfit_driver);
 }
 
 static __exit void nfit_exit(void)

Patches currently in stable-queue which might be from [email protected] are

queue-4.12/acpi-nfit-fix-memory-corruption-unregister-mce-decoder-on-failure.patch