acpi/nfit: Fix memory corruption/Unregister mce decoder on failure
Subsystems (2)
PATCH RESEND v2 1/1 acpi/nfit: Fix memory corruption/Unregister mce decoder on failure
I somehow managed to trim off the cc list ... oops. Sorry about that.
P.
----8<----
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
--- drivers/acpi/nfit/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/acpi/nfit/core.c +7 -1
@@ -3043,6 +3043,8 @@ static void acpi_nfit_notify(struct acpi_device *adev, u32 event)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,12 @@ static __init int nfit_init(void)return -ENOMEM ;nfit_mce_register (); + ret =acpi_bus_register_driver (&acpi_nfit_driver); +if (ret) +nfit_mce_unregister (); + +return ret; -return acpi_bus_register_driver (&acpi_nfit_driver); } static __exit void nfit_exit(void)
Signature · 1 line
1.7.9.3
Quoted 11 lines · Prarit Bhargava
I somehow managed to trim off the cc list ... oops. Sorry about that.
P.
----8<----
nfit_init()callsnfit_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.
Quoted 5 lines
Unregister the nfit mce decoder on module init failure.
[v2]: register and then unregister mce handler to avoid losing mce events
Signed-off-by Prarit Bhargava <[email protected]>
Looks good to me.
Quoted 23 lines · Prarit Bhargava
I somehow managed to trim off the cc list ... oops. Sorry about that.
P.
----8<----
nfit_init()callsnfit_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
Signed-off-by Prarit Bhargava <[email protected]>Cc Jeff Moyer <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Len Brown <[email protected]>Cc Dan Williams <[email protected]>Cc Vishal Verma <[email protected]>Cc "Lee, Chun-Yi" <[email protected]>Cc Linda Knippers <[email protected]>
Quoted 4 lines
--- drivers/acpi/nfit/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Looks good,
Quoted 30 lines
drivers/acpi/nfit/core.c +7
-1@@ -3043,6 +3043,8 @@ static void acpi_nfit_notify(struct acpi_device *adev, u32 event)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,12 @@ static __init int nfit_init(void)return -ENOMEM ;nfit_mce_register (); + ret =acpi_bus_register_driver (&acpi_nfit_driver); +if (ret) +nfit_mce_unregister (); + +return ret; -return acpi_bus_register_driver (&acpi_nfit_driver); } static __exit void nfit_exit(void)Signature · 1 line
1.7.9.3