From 59911be7e5ab7f1d02bceb956f05455c594cdc47 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 7 Sep 2021 07:58:26 +0200 Subject: [PATCH] Revert "once: Fix panic when module unload" This reverts commit 6815e21fe28ddfe8f55b4ca53031957dcd65843a which is commit 1027b96ec9d34f9abab69bc1a4dc5b1ad8ab1349 upstream. The function __do_once_done() added a new parameter to handle the problem when unloading modules with that function in it. Android does not support module unloading so just revert this as it breaks the kabi. Signed-off-by: Greg Kroah-Hartman Change-Id: I4d5279c00c64f2f1836837c13c27cea5ed3ea073 --- include/linux/once.h | 4 ++-- lib/once.c | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/include/linux/once.h b/include/linux/once.h index ae6f4eb41cbe..9225ee6d96c7 100644 --- a/include/linux/once.h +++ b/include/linux/once.h @@ -7,7 +7,7 @@ bool __do_once_start(bool *done, unsigned long *flags); void __do_once_done(bool *done, struct static_key_true *once_key, - unsigned long *flags, struct module *mod); + unsigned long *flags); /* Call a function exactly once. The idea of DO_ONCE() is to perform * a function call such as initialization of random seeds, etc, only @@ -46,7 +46,7 @@ void __do_once_done(bool *done, struct static_key_true *once_key, if (unlikely(___ret)) { \ func(__VA_ARGS__); \ __do_once_done(&___done, &___once_key, \ - &___flags, THIS_MODULE); \ + &___flags); \ } \ } \ ___ret; \ diff --git a/lib/once.c b/lib/once.c index 59149bf3bfb4..8b7d6235217e 100644 --- a/lib/once.c +++ b/lib/once.c @@ -3,12 +3,10 @@ #include #include #include -#include struct once_work { struct work_struct work; struct static_key_true *key; - struct module *module; }; static void once_deferred(struct work_struct *w) @@ -18,11 +16,10 @@ static void once_deferred(struct work_struct *w) work = container_of(w, struct once_work, work); BUG_ON(!static_key_enabled(work->key)); static_branch_disable(work->key); - module_put(work->module); kfree(work); } -static void once_disable_jump(struct static_key_true *key, struct module *mod) +static void once_disable_jump(struct static_key_true *key) { struct once_work *w; @@ -32,8 +29,6 @@ static void once_disable_jump(struct static_key_true *key, struct module *mod) INIT_WORK(&w->work, once_deferred); w->key = key; - w->module = mod; - __module_get(mod); schedule_work(&w->work); } @@ -58,11 +53,11 @@ bool __do_once_start(bool *done, unsigned long *flags) EXPORT_SYMBOL(__do_once_start); void __do_once_done(bool *done, struct static_key_true *once_key, - unsigned long *flags, struct module *mod) + unsigned long *flags) __releases(once_lock) { *done = true; spin_unlock_irqrestore(&once_lock, *flags); - once_disable_jump(once_key, mod); + once_disable_jump(once_key); } EXPORT_SYMBOL(__do_once_done);