Commit 0340a6b7 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

module: Fix up module_notifier return values

While auditing all module notifiers I noticed a whole bunch of fail
wrt the return value. Notifiers have a 'special' return semantics.

As is; NOTIFY_DONE vs NOTIFY_OK is a bit vague; but
notifier_from_errno(0) results in NOTIFY_OK and NOTIFY_DONE has a
comment that says "Don't care".

From this I've used NOTIFY_DONE when the function completely ignores
the callback and notifier_to_error() isn't used.
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Reviewed-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Reviewed-by: default avatarJoel Fernandes (Google) <joel@joelfernandes.org>
Reviewed-by: default avatarRobert Richter <rric@kernel.org>
Acked-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
Link: https://lore.kernel.org/r/20200818135804.385360407@infradead.org
parent 70d93298
...@@ -116,7 +116,7 @@ module_load_notify(struct notifier_block *self, unsigned long val, void *data) ...@@ -116,7 +116,7 @@ module_load_notify(struct notifier_block *self, unsigned long val, void *data)
{ {
#ifdef CONFIG_MODULES #ifdef CONFIG_MODULES
if (val != MODULE_STATE_COMING) if (val != MODULE_STATE_COMING)
return 0; return NOTIFY_DONE;
/* FIXME: should we process all CPU buffers ? */ /* FIXME: should we process all CPU buffers ? */
mutex_lock(&buffer_mutex); mutex_lock(&buffer_mutex);
...@@ -124,7 +124,7 @@ module_load_notify(struct notifier_block *self, unsigned long val, void *data) ...@@ -124,7 +124,7 @@ module_load_notify(struct notifier_block *self, unsigned long val, void *data)
add_event_entry(MODULE_LOADED_CODE); add_event_entry(MODULE_LOADED_CODE);
mutex_unlock(&buffer_mutex); mutex_unlock(&buffer_mutex);
#endif #endif
return 0; return NOTIFY_OK;
} }
......
...@@ -2027,10 +2027,11 @@ static int bpf_event_notify(struct notifier_block *nb, unsigned long op, ...@@ -2027,10 +2027,11 @@ static int bpf_event_notify(struct notifier_block *nb, unsigned long op,
{ {
struct bpf_trace_module *btm, *tmp; struct bpf_trace_module *btm, *tmp;
struct module *mod = module; struct module *mod = module;
int ret = 0;
if (mod->num_bpf_raw_events == 0 || if (mod->num_bpf_raw_events == 0 ||
(op != MODULE_STATE_COMING && op != MODULE_STATE_GOING)) (op != MODULE_STATE_COMING && op != MODULE_STATE_GOING))
return 0; goto out;
mutex_lock(&bpf_module_mutex); mutex_lock(&bpf_module_mutex);
...@@ -2040,6 +2041,8 @@ static int bpf_event_notify(struct notifier_block *nb, unsigned long op, ...@@ -2040,6 +2041,8 @@ static int bpf_event_notify(struct notifier_block *nb, unsigned long op,
if (btm) { if (btm) {
btm->module = module; btm->module = module;
list_add(&btm->list, &bpf_trace_modules); list_add(&btm->list, &bpf_trace_modules);
} else {
ret = -ENOMEM;
} }
break; break;
case MODULE_STATE_GOING: case MODULE_STATE_GOING:
...@@ -2055,7 +2058,8 @@ static int bpf_event_notify(struct notifier_block *nb, unsigned long op, ...@@ -2055,7 +2058,8 @@ static int bpf_event_notify(struct notifier_block *nb, unsigned long op,
mutex_unlock(&bpf_module_mutex); mutex_unlock(&bpf_module_mutex);
return 0; out:
return notifier_from_errno(ret);
} }
static struct notifier_block bpf_module_nb = { static struct notifier_block bpf_module_nb = {
......
...@@ -9072,7 +9072,7 @@ static int trace_module_notify(struct notifier_block *self, ...@@ -9072,7 +9072,7 @@ static int trace_module_notify(struct notifier_block *self,
break; break;
} }
return 0; return NOTIFY_OK;
} }
static struct notifier_block trace_module_nb = { static struct notifier_block trace_module_nb = {
......
...@@ -2646,7 +2646,7 @@ static int trace_module_notify(struct notifier_block *self, ...@@ -2646,7 +2646,7 @@ static int trace_module_notify(struct notifier_block *self,
mutex_unlock(&trace_types_lock); mutex_unlock(&trace_types_lock);
mutex_unlock(&event_mutex); mutex_unlock(&event_mutex);
return 0; return NOTIFY_OK;
} }
static struct notifier_block trace_module_nb = { static struct notifier_block trace_module_nb = {
......
...@@ -96,7 +96,7 @@ static int module_trace_bprintk_format_notify(struct notifier_block *self, ...@@ -96,7 +96,7 @@ static int module_trace_bprintk_format_notify(struct notifier_block *self,
if (val == MODULE_STATE_COMING) if (val == MODULE_STATE_COMING)
hold_module_trace_bprintk_format(start, end); hold_module_trace_bprintk_format(start, end);
} }
return 0; return NOTIFY_OK;
} }
/* /*
...@@ -174,7 +174,7 @@ __init static int ...@@ -174,7 +174,7 @@ __init static int
module_trace_bprintk_format_notify(struct notifier_block *self, module_trace_bprintk_format_notify(struct notifier_block *self,
unsigned long val, void *data) unsigned long val, void *data)
{ {
return 0; return NOTIFY_OK;
} }
static inline const char ** static inline const char **
find_next_mod_format(int start_index, void *v, const char **fmt, loff_t *pos) find_next_mod_format(int start_index, void *v, const char **fmt, loff_t *pos)
......
...@@ -521,7 +521,7 @@ static int tracepoint_module_notify(struct notifier_block *self, ...@@ -521,7 +521,7 @@ static int tracepoint_module_notify(struct notifier_block *self,
case MODULE_STATE_UNFORMED: case MODULE_STATE_UNFORMED:
break; break;
} }
return ret; return notifier_from_errno(ret);
} }
static struct notifier_block tracepoint_module_nb = { static struct notifier_block tracepoint_module_nb = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment