From: wu000273@umn.edu
To: kjlu@umn.edu
Cc: wu000273@umn.edu, Ryusuke Konishi <konishi.ryusuke@gmail.com>,
Vyacheslav Dubeyko <Vyacheslav.Dubeyko@hgst.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-nilfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] nilfs2: Fix reference count leak in nilfs_sysfs_create_device_group
Date: Wed, 27 May 2020 15:09:33 -0500 [thread overview]
Message-ID: <20200527200933.31135-1-wu000273@umn.edu> (raw)
From: Qiushi Wu <wu000273@umn.edu>
kobject_init_and_add() takes reference even when it fails.
In nilfs_sysfs_create_device_group(), the memory allocated by
kobject_init_and_add() is not freed when kobject_init_and_add()
fails. Thus replace the jump target "free_dev_subgroups" by
"cleanup_dev_kobject".
Fixes: da7141fb78db ("nilfs2: add /sys/fs/nilfs2/<device> group")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
---
fs/nilfs2/sysfs.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c
index e60be7bb55b0..4a74756d52fe 100644
--- a/fs/nilfs2/sysfs.c
+++ b/fs/nilfs2/sysfs.c
@@ -1000,7 +1000,7 @@ int nilfs_sysfs_create_device_group(struct super_block *sb)
err = kobject_init_and_add(&nilfs->ns_dev_kobj, &nilfs_dev_ktype, NULL,
"%s", sb->s_id);
if (err)
- goto free_dev_subgroups;
+ goto cleanup_dev_kobject;
err = nilfs_sysfs_create_mounted_snapshots_group(nilfs);
if (err)
@@ -1038,8 +1038,6 @@ int nilfs_sysfs_create_device_group(struct super_block *sb)
cleanup_dev_kobject:
kobject_del(&nilfs->ns_dev_kobj);
-
-free_dev_subgroups:
kfree(nilfs->ns_dev_subgroups);
failed_create_device_group:
--
2.17.1
next reply other threads:[~2020-05-27 20:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-27 20:09 wu000273 [this message]
2020-05-27 22:21 ` [PATCH] nilfs2: Fix reference count leak in nilfs_sysfs_create_device_group Ryusuke Konishi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200527200933.31135-1-wu000273@umn.edu \
--to=wu000273@umn.edu \
--cc=Vyacheslav.Dubeyko@hgst.com \
--cc=akpm@linux-foundation.org \
--cc=kjlu@umn.edu \
--cc=konishi.ryusuke@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nilfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).