summaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorRiccardo Schirone <sirmy15@gmail.com>2018-01-11 14:28:13 -0500
committerTheodore Ts'o <tytso@mit.edu>2018-01-11 14:28:13 -0500
commit95c4df029374d8c09ad36c961e7a14a1d3ac6a6f (patch)
treef5a9cd8c23ea7328a5babedd0cab8763074305a2 /fs/ext4
parenta794df0ecdd557961a0302062f5a7a5f500a8542 (diff)
downloadop-kernel-dev-95c4df029374d8c09ad36c961e7a14a1d3ac6a6f.zip
op-kernel-dev-95c4df029374d8c09ad36c961e7a14a1d3ac6a6f.tar.gz
ext4: release kobject/kset even when init/register fail
Even when kobject_init_and_add/kset_register fail, the kobject has been already initialized and the refcount set to 1. Thus it is necessary to release the kobject/kset, to avoid the memory associated with it hanging around forever. Signed-off-by: Riccardo Schirone <sirmy15@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/sysfs.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
index e21afd5..4389fe4 100644
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -396,8 +396,11 @@ int ext4_register_sysfs(struct super_block *sb)
init_completion(&sbi->s_kobj_unregister);
err = kobject_init_and_add(&sbi->s_kobj, &ext4_sb_ktype, NULL,
"%s", sb->s_id);
- if (err)
+ if (err) {
+ kobject_put(&sbi->s_kobj);
+ wait_for_completion(&sbi->s_kobj_unregister);
return err;
+ }
if (ext4_proc_root)
sbi->s_proc = proc_mkdir(sb->s_id, ext4_proc_root);
@@ -430,15 +433,19 @@ int __init ext4_init_sysfs(void)
kobject_set_name(&ext4_kset.kobj, "ext4");
ext4_kset.kobj.parent = fs_kobj;
ret = kset_register(&ext4_kset);
- if (ret)
+ if (ret) {
+ kset_unregister(&ext4_kset);
return ret;
+ }
ret = kobject_init_and_add(&ext4_feat, &ext4_feat_ktype,
NULL, "features");
- if (ret)
+ if (ret) {
+ kobject_put(&ext4_feat);
kset_unregister(&ext4_kset);
- else
+ } else {
ext4_proc_root = proc_mkdir(proc_dirname, NULL);
+ }
return ret;
}
OpenPOWER on IntegriCloud