All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kernel/module.c: fix warning about unused nowarn variable
@ 2017-06-02 12:05 Corentin Labbe
  2017-06-06  5:09 ` Jessica Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Corentin Labbe @ 2017-06-02 12:05 UTC (permalink / raw)
  To: jeyu, rusty; +Cc: linux-kernel, Corentin Labbe

This patch fix the following warning:
kernel/module.c: In function 'add_usage_links':
kernel/module.c:1653:6: warning: variable 'nowarn' set but not used [-Wunused-but-set-variable]
  int nowarn;

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 kernel/module.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index e3e9dbba6a5b..aed902bcb4aa 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1663,19 +1663,20 @@ static inline void remove_notes_attrs(struct module *mod)
 }
 #endif /* CONFIG_KALLSYMS */
 
-static void add_usage_links(struct module *mod)
+static int add_usage_links(struct module *mod)
 {
+	int ret = 0;
 #ifdef CONFIG_MODULE_UNLOAD
 	struct module_use *use;
-	int nowarn;
 
 	mutex_lock(&module_mutex);
 	list_for_each_entry(use, &mod->target_list, target_list) {
-		nowarn = sysfs_create_link(use->target->holders_dir,
+		ret = sysfs_create_link(use->target->holders_dir,
 					   &mod->mkobj.kobj, mod->name);
 	}
 	mutex_unlock(&module_mutex);
 #endif
+	return ret;
 }
 
 static void del_usage_links(struct module *mod)
@@ -1798,13 +1799,17 @@ static int mod_sysfs_setup(struct module *mod,
 	if (err)
 		goto out_unreg_param;
 
-	add_usage_links(mod);
+	err = add_usage_links(mod);
+	if (err)
+		goto out_unreg_usage_links;
 	add_sect_attrs(mod, info);
 	add_notes_attrs(mod, info);
 
 	kobject_uevent(&mod->mkobj.kobj, KOBJ_ADD);
 	return 0;
 
+out_unreg_usage_links:
+	module_remove_modinfo_attrs(mod);
 out_unreg_param:
 	module_param_sysfs_remove(mod);
 out_unreg_holders:
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-06  6:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-02 12:05 [PATCH] kernel/module.c: fix warning about unused nowarn variable Corentin Labbe
2017-06-06  5:09 ` Jessica Yu
2017-06-06  6:38   ` Corentin Labbe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.