aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/module.c
diff options
context:
space:
mode:
authorCorentin Labbe <clabbe.montjoie@gmail.com>2017-06-06 08:17:39 -0400
committerJessica Yu <jeyu@kernel.org>2017-06-26 11:23:19 -0400
commit1ba5c08b58a0c21fca222f1bf2fde184aa26103f (patch)
tree958a979940db979133f522dde5c722575109d957 /kernel/module.c
parent3e2e857f9c3a19d55ee0ba7b428b8be5008960bf (diff)
kernel/module.c: suppress warning about unused nowarn variable
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] [jeyu: folded in first patch since it only swapped the function order so that del_usage_links can be called from add_usage_links] Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com> Signed-off-by: Jessica Yu <jeyu@kernel.org>
Diffstat (limited to 'kernel/module.c')
-rw-r--r--kernel/module.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/kernel/module.c b/kernel/module.c
index 3803449ca219..f546d574f436 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1666,31 +1666,36 @@ static inline void remove_notes_attrs(struct module *mod)
1666} 1666}
1667#endif /* CONFIG_KALLSYMS */ 1667#endif /* CONFIG_KALLSYMS */
1668 1668
1669static void add_usage_links(struct module *mod) 1669static void del_usage_links(struct module *mod)
1670{ 1670{
1671#ifdef CONFIG_MODULE_UNLOAD 1671#ifdef CONFIG_MODULE_UNLOAD
1672 struct module_use *use; 1672 struct module_use *use;
1673 int nowarn;
1674 1673
1675 mutex_lock(&module_mutex); 1674 mutex_lock(&module_mutex);
1676 list_for_each_entry(use, &mod->target_list, target_list) { 1675 list_for_each_entry(use, &mod->target_list, target_list)
1677 nowarn = sysfs_create_link(use->target->holders_dir, 1676 sysfs_remove_link(use->target->holders_dir, mod->name);
1678 &mod->mkobj.kobj, mod->name);
1679 }
1680 mutex_unlock(&module_mutex); 1677 mutex_unlock(&module_mutex);
1681#endif 1678#endif
1682} 1679}
1683 1680
1684static void del_usage_links(struct module *mod) 1681static int add_usage_links(struct module *mod)
1685{ 1682{
1683 int ret = 0;
1686#ifdef CONFIG_MODULE_UNLOAD 1684#ifdef CONFIG_MODULE_UNLOAD
1687 struct module_use *use; 1685 struct module_use *use;
1688 1686
1689 mutex_lock(&module_mutex); 1687 mutex_lock(&module_mutex);
1690 list_for_each_entry(use, &mod->target_list, target_list) 1688 list_for_each_entry(use, &mod->target_list, target_list) {
1691 sysfs_remove_link(use->target->holders_dir, mod->name); 1689 ret = sysfs_create_link(use->target->holders_dir,
1690 &mod->mkobj.kobj, mod->name);
1691 if (ret)
1692 break;
1693 }
1692 mutex_unlock(&module_mutex); 1694 mutex_unlock(&module_mutex);
1695 if (ret)
1696 del_usage_links(mod);
1693#endif 1697#endif
1698 return ret;
1694} 1699}
1695 1700
1696static int module_add_modinfo_attrs(struct module *mod) 1701static int module_add_modinfo_attrs(struct module *mod)
@@ -1801,13 +1806,18 @@ static int mod_sysfs_setup(struct module *mod,
1801 if (err) 1806 if (err)
1802 goto out_unreg_param; 1807 goto out_unreg_param;
1803 1808
1804 add_usage_links(mod); 1809 err = add_usage_links(mod);
1810 if (err)
1811 goto out_unreg_modinfo_attrs;
1812
1805 add_sect_attrs(mod, info); 1813 add_sect_attrs(mod, info);
1806 add_notes_attrs(mod, info); 1814 add_notes_attrs(mod, info);
1807 1815
1808 kobject_uevent(&mod->mkobj.kobj, KOBJ_ADD); 1816 kobject_uevent(&mod->mkobj.kobj, KOBJ_ADD);
1809 return 0; 1817 return 0;
1810 1818
1819out_unreg_modinfo_attrs:
1820 module_remove_modinfo_attrs(mod);
1811out_unreg_param: 1821out_unreg_param:
1812 module_param_sysfs_remove(mod); 1822 module_param_sysfs_remove(mod);
1813out_unreg_holders: 1823out_unreg_holders: