Skip to content

Commit

Permalink
ACPI / SBS: Fix rare oops when removing modules
Browse files Browse the repository at this point in the history
There was a small race when removing the sbshc module where
smbus_alarm() had queued acpi_smbus_callback() for deferred execution
but it hadn't been run yet, so that when it did run hc had been freed
and the module unloaded, resulting in an invalid paging request.

A similar race existed when removing the sbs module with regards to
acpi_sbs_callback() (which is called from acpi_smbus_callback()).

We therefore need to ensure no callbacks are pending or executing before
the cleanups are done and the modules are removed.

Signed-off-by: Ronald Tschalär <ronald@innovation.ch>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Ronald Tschalär authored and Rafael J. Wysocki committed Oct 8, 2018
1 parent ca1721c commit 757c968
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/acpi/osl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,7 @@ void acpi_os_wait_events_complete(void)
flush_workqueue(kacpid_wq);
flush_workqueue(kacpi_notify_wq);
}
EXPORT_SYMBOL(acpi_os_wait_events_complete);

struct acpi_hp_work {
struct work_struct work;
Expand Down
2 changes: 2 additions & 0 deletions drivers/acpi/sbshc.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ int acpi_smbus_unregister_callback(struct acpi_smb_hc *hc)
hc->callback = NULL;
hc->context = NULL;
mutex_unlock(&hc->lock);
acpi_os_wait_events_complete();
return 0;
}

Expand Down Expand Up @@ -292,6 +293,7 @@ static int acpi_smbus_hc_remove(struct acpi_device *device)

hc = acpi_driver_data(device);
acpi_ec_remove_query_handler(hc->ec, hc->query_bit);
acpi_os_wait_events_complete();
kfree(hc);
device->driver_data = NULL;
return 0;
Expand Down

0 comments on commit 757c968

Please sign in to comment.