Revert "once: Fix panic when module unload"

This reverts commit 57bd5b59f1 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 <gregkh@google.com>
Change-Id: I4d5279c00c64f2f1836837c13c27cea5ed3ea073
This commit is contained in:
Greg Kroah-Hartman 2021-09-07 07:58:26 +02:00
parent 2e0ca55ea4
commit 8ac6727e49
2 changed files with 5 additions and 10 deletions

View File

@ -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; \

View File

@ -3,12 +3,10 @@
#include <linux/spinlock.h>
#include <linux/once.h>
#include <linux/random.h>
#include <linux/module.h>
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);