[PATCH v2 11/23] dynamic_debug: move pr_err from module.c to ddebug_add_module

From: Rasmus Villemoes
Date: Tue Oct 09 2018 - 07:20:43 EST


This serves two purposes: First, we get a diagnostic if (though
extremely unlikely), any of the calls of ddebug_add_module for built-in
code fails, effectively disabling dynamic_debug. Second, I want to make
struct _ddebug opaque, and avoid accessing any of its members outside
dynamic_debug.[ch].

Acked-by: Jason Baron <jbaron@xxxxxxxxxx>
Signed-off-by: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>
---
kernel/module.c | 4 +---
lib/dynamic_debug.c | 4 +++-
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index 6746c85511fe..381f9bf282fe 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2716,9 +2716,7 @@ static void dynamic_debug_setup(struct module *mod, struct _ddebug *debug, unsig
if (!debug)
return;
#ifdef CONFIG_DYNAMIC_DEBUG
- if (ddebug_add_module(debug, num, mod->name))
- pr_err("dynamic debug error adding module: %s\n",
- debug->modname);
+ ddebug_add_module(debug, num, mod->name);
#endif
}

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index f1de45a100fa..e90459dca34b 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -849,8 +849,10 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
struct ddebug_table *dt;

dt = kzalloc(sizeof(*dt), GFP_KERNEL);
- if (dt == NULL)
+ if (dt == NULL) {
+ pr_err("error adding module: %s\n", name);
return -ENOMEM;
+ }
/*
* For built-in modules, name lives in .rodata and is
* immortal. For loaded modules, name points at the name[]
--
2.19.1.3.g1d92a00e68