aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobin C. Harding <tobin@kernel.org>2019-05-31 22:30:29 -0700
committerPaul Gortmaker <paul.gortmaker@windriver.com>2019-09-16 12:21:45 -0400
commit66a72b9a80189cb6a182fb9ba3838c33971936b5 (patch)
treee529da8e58ac33ce89491ec4629e84e6f37bc701
parent409347c45d3993776b9891ffb2cc40b2b8b8236d (diff)
downloadlinux-yocto-66a72b9a80189cb6a182fb9ba3838c33971936b5.tar.gz
linux-yocto-66a72b9a80189cb6a182fb9ba3838c33971936b5.tar.bz2
linux-yocto-66a72b9a80189cb6a182fb9ba3838c33971936b5.zip
ocfs2: fix error path kobject memory leak
commit b9fba67b3806e21b98bd5a98dc3921a8e9b42d61 upstream. If a call to kobject_init_and_add() fails we should call kobject_put() otherwise we leak memory. Add call to kobject_put() in the error path of call to kobject_init_and_add(). Please note, this has the side effect that the release method is called if kobject_init_and_add() fails. Link: http://lkml.kernel.org/r/20190513033458.2824-1-tobin@kernel.org Signed-off-by: Tobin C. Harding <tobin@kernel.org> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> Cc: Mark Fasheh <mark@fasheh.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Changwei Ge <gechangwei@live.cn> Cc: Gang He <ghe@suse.com> Cc: Jun Piao <piaojun@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
-rw-r--r--fs/ocfs2/filecheck.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/ocfs2/filecheck.c b/fs/ocfs2/filecheck.c
index f65f2b2f594d..1906cc962c4d 100644
--- a/fs/ocfs2/filecheck.c
+++ b/fs/ocfs2/filecheck.c
@@ -193,6 +193,7 @@ int ocfs2_filecheck_create_sysfs(struct ocfs2_super *osb)
ret = kobject_init_and_add(&entry->fs_kobj, &ocfs2_ktype_filecheck,
NULL, "filecheck");
if (ret) {
+ kobject_put(&entry->fs_kobj);
kfree(fcheck);
return ret;
}