Skip to content

Commit

Permalink
acpi/nfit: Fix memory corruption/Unregister mce decoder on failure
Browse files Browse the repository at this point in the history
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: 6839a6d ("nfit: do an ARS scrub on hitting a latent media error")
Cc: <[email protected]>
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]>
Cc: [email protected]
Acked-by: Jeff Moyer <[email protected]>
Signed-off-by: Prarit Bhargava <[email protected]>
Reviewed-by: Vishal Verma <[email protected]>
Signed-off-by: Dan Williams <[email protected]>
  • Loading branch information
prarit authored and djbw committed Jul 17, 2017
1 parent 43fe51e commit 7e700d2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/acpi/nfit/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3160,6 +3160,8 @@ static struct acpi_driver acpi_nfit_driver = {

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);
Expand Down Expand Up @@ -3187,8 +3189,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)
Expand Down

0 comments on commit 7e700d2

Please sign in to comment.