Skip to content

Commit 7e700d2

Browse files
praritdjbw
authored andcommitted
acpi/nfit: Fix memory corruption/Unregister mce decoder on failure
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]>
1 parent 43fe51e commit 7e700d2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/acpi/nfit/core.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3160,6 +3160,8 @@ static struct acpi_driver acpi_nfit_driver = {
31603160

31613161
static __init int nfit_init(void)
31623162
{
3163+
int ret;
3164+
31633165
BUILD_BUG_ON(sizeof(struct acpi_table_nfit) != 40);
31643166
BUILD_BUG_ON(sizeof(struct acpi_nfit_system_address) != 56);
31653167
BUILD_BUG_ON(sizeof(struct acpi_nfit_memory_map) != 48);
@@ -3187,8 +3189,14 @@ static __init int nfit_init(void)
31873189
return -ENOMEM;
31883190

31893191
nfit_mce_register();
3192+
ret = acpi_bus_register_driver(&acpi_nfit_driver);
3193+
if (ret) {
3194+
nfit_mce_unregister();
3195+
destroy_workqueue(nfit_wq);
3196+
}
3197+
3198+
return ret;
31903199

3191-
return acpi_bus_register_driver(&acpi_nfit_driver);
31923200
}
31933201

31943202
static __exit void nfit_exit(void)

0 commit comments

Comments
 (0)