aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2017-03-06 15:42:12 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-05-20 08:28:42 -0400
commit9ee8502bd2cc83b5c11e2f255ad233ed823d9909 (patch)
tree0dce18bfd153b5e2973c9dcbccd1d2c48a741e57
parenta4de9300862540cc9bb8ef9b665405bed79c28e7 (diff)
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.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 14984d902a99..43033a3d66d5 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -704,6 +704,7 @@ int pstore_register(struct pstore_info *psi)
704 if (psi->flags & PSTORE_FLAGS_PMSG) 704 if (psi->flags & PSTORE_FLAGS_PMSG)
705 pstore_register_pmsg(); 705 pstore_register_pmsg();
706 706
707 /* Start watching for new records, if desired. */
707 if (pstore_update_ms >= 0) { 708 if (pstore_update_ms >= 0) {
708 pstore_timer.expires = jiffies + 709 pstore_timer.expires = jiffies +
709 msecs_to_jiffies(pstore_update_ms); 710 msecs_to_jiffies(pstore_update_ms);
@@ -726,6 +727,11 @@ EXPORT_SYMBOL_GPL(pstore_register);
726 727
727void pstore_unregister(struct pstore_info *psi) 728void pstore_unregister(struct pstore_info *psi)
728{ 729{
730 /* Stop timer and make sure all work has finished. */
731 pstore_update_ms = -1;
732 del_timer_sync(&pstore_timer);
733 flush_work(&pstore_work);
734
729 if (psi->flags & PSTORE_FLAGS_PMSG) 735 if (psi->flags & PSTORE_FLAGS_PMSG)
730 pstore_unregister_pmsg(); 736 pstore_unregister_pmsg();
731 if (psi->flags & PSTORE_FLAGS_FTRACE) 737 if (psi->flags & PSTORE_FLAGS_FTRACE)
@@ -825,7 +831,9 @@ static void pstore_timefunc(unsigned long dummy)
825 schedule_work(&pstore_work); 831 schedule_work(&pstore_work);
826 } 832 }
827 833
828 mod_timer(&pstore_timer, jiffies + msecs_to_jiffies(pstore_update_ms)); 834 if (pstore_update_ms >= 0)
835 mod_timer(&pstore_timer,
836 jiffies + msecs_to_jiffies(pstore_update_ms));
829} 837}
830 838
831module_param(backend, charp, 0444); 839module_param(backend, charp, 0444);