diff options
author | Kees Cook <keescook@chromium.org> | 2017-03-06 23:42:12 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-05-20 15:31:04 +0300 |
commit | 291e716bb382710d0685d6d1c8c1ac02551e70f8 (patch) | |
tree | c0ab8e006345906d757280d5a49f710d67500d42 | |
parent | e5590e3d92754b85629d2a06d70bb5b09c2165c9 (diff) | |
download | linux-291e716bb382710d0685d6d1c8c1ac02551e70f8.tar.xz |
pstore: Shut down worker when unregistering
commit 6330d5534786d5315d56d558aa6d20740f97d80a upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | fs/pstore/platform.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 729677e18e36..8e6ae68abf8d 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -705,6 +705,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); @@ -727,6 +728,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) @@ -826,7 +832,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); |