Commit 97c146ef authored by Kay Sievers's avatar Kay Sievers Committed by Greg Kroah-Hartman

sysfs: fix /sys/module/*/holders after sysfs logic change

Sysfs symlinks now require fully registered kobjects as a target,
otherwise the call to create a symlink will fail. Here we register
the kobject before we request the symlink in the holders directory.
Signed-off-by: default avatarKay Sievers <kay.sievers@vrfy.org>
Cc: Tejun Heo <teheo@suse.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent da231fd5
...@@ -1227,6 +1227,8 @@ int mod_sysfs_init(struct module *mod) ...@@ -1227,6 +1227,8 @@ int mod_sysfs_init(struct module *mod)
kobject_init(&mod->mkobj.kobj); kobject_init(&mod->mkobj.kobj);
/* delay uevent until full sysfs population */
err = kobject_add(&mod->mkobj.kobj);
out: out:
return err; return err;
} }
...@@ -1237,11 +1239,6 @@ int mod_sysfs_setup(struct module *mod, ...@@ -1237,11 +1239,6 @@ int mod_sysfs_setup(struct module *mod,
{ {
int err; int err;
/* delay uevent until full sysfs population */
err = kobject_add(&mod->mkobj.kobj);
if (err)
goto out;
mod->holders_dir = kobject_create_and_add("holders", &mod->mkobj.kobj); mod->holders_dir = kobject_create_and_add("holders", &mod->mkobj.kobj);
if (!mod->holders_dir) { if (!mod->holders_dir) {
err = -ENOMEM; err = -ENOMEM;
...@@ -1266,7 +1263,6 @@ int mod_sysfs_setup(struct module *mod, ...@@ -1266,7 +1263,6 @@ int mod_sysfs_setup(struct module *mod,
out_unreg: out_unreg:
kobject_del(&mod->mkobj.kobj); kobject_del(&mod->mkobj.kobj);
kobject_put(&mod->mkobj.kobj); kobject_put(&mod->mkobj.kobj);
out:
return err; return err;
} }
#endif #endif
...@@ -1883,10 +1879,10 @@ static struct module *load_module(void __user *umod, ...@@ -1883,10 +1879,10 @@ static struct module *load_module(void __user *umod,
/* Now we've moved module, initialize linked lists, etc. */ /* Now we've moved module, initialize linked lists, etc. */
module_unload_init(mod); module_unload_init(mod);
/* Initialize kobject, so we can reference it. */ /* add kobject, so we can reference it. */
err = mod_sysfs_init(mod); err = mod_sysfs_init(mod);
if (err) if (err)
goto cleanup; goto free_unload;
/* Set up license info based on the info section */ /* Set up license info based on the info section */
set_license(mod, get_modinfo(sechdrs, infoindex, "license")); set_license(mod, get_modinfo(sechdrs, infoindex, "license"));
...@@ -2056,6 +2052,9 @@ static struct module *load_module(void __user *umod, ...@@ -2056,6 +2052,9 @@ static struct module *load_module(void __user *umod,
arch_cleanup: arch_cleanup:
module_arch_cleanup(mod); module_arch_cleanup(mod);
cleanup: cleanup:
kobject_del(&mod->mkobj.kobj);
kobject_put(&mod->mkobj.kobj);
free_unload:
module_unload_free(mod); module_unload_free(mod);
module_free(mod, mod->module_init); module_free(mod, mod->module_init);
free_core: free_core:
......
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