Skip to content

Commit

Permalink
pstore: Shut down worker when unregistering
Browse files Browse the repository at this point in the history
When built as a module and running with update_ms >= 0, pstore will Oops
during module unload since the work timer is still running. This makes sure
the worker is stopped before unloading.

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: stable@vger.kernel.org
  • Loading branch information
Kees Cook committed Mar 7, 2017
1 parent e9a330c commit 6330d55
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion fs/pstore/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ int pstore_register(struct pstore_info *psi)
if (psi->flags & PSTORE_FLAGS_PMSG)
pstore_register_pmsg();

/* Start watching for new records, if desired. */
if (pstore_update_ms >= 0) {
pstore_timer.expires = jiffies +
msecs_to_jiffies(pstore_update_ms);
Expand All @@ -731,6 +732,11 @@ EXPORT_SYMBOL_GPL(pstore_register);

void pstore_unregister(struct pstore_info *psi)
{
/* Stop timer and make sure all work has finished. */
pstore_update_ms = -1;
del_timer_sync(&pstore_timer);
flush_work(&pstore_work);

if (psi->flags & PSTORE_FLAGS_PMSG)
pstore_unregister_pmsg();
if (psi->flags & PSTORE_FLAGS_FTRACE)
Expand Down Expand Up @@ -830,7 +836,9 @@ static void pstore_timefunc(unsigned long dummy)
schedule_work(&pstore_work);
}

mod_timer(&pstore_timer, jiffies + msecs_to_jiffies(pstore_update_ms));
if (pstore_update_ms >= 0)
mod_timer(&pstore_timer,
jiffies + msecs_to_jiffies(pstore_update_ms));
}

module_param(backend, charp, 0444);
Expand Down

0 comments on commit 6330d55

Please sign in to comment.