From: Lin Yi <teroincn@163.com>
To: axboe@kernel.dk
Cc: linux-block@vger.kernel.org, liujian6@iie.ac.cn,
csong@cs.ucr.edu, zhiyunq@cs.ucr.edu, yiqiuping@gmail.com,
teroincn@163.com
Subject: [PATCH] block :blk-sysfs: fix refcount imbalance on the error path
Date: Mon, 3 Jun 2019 15:46:53 +0800 [thread overview]
Message-ID: <20190603074653.GA12767@163.com> (raw)
kobject_add takes a refcount to the object dev->kobj, but forget to
release it on the error path, lead to a memory leak.
Signed-off-by: Lin Yi <teroincn@163.com>
---
block/blk-sysfs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 75b5281..539b7cb 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -971,6 +971,7 @@ int blk_register_queue(struct gendisk *disk)
ret = kobject_add(&q->kobj, kobject_get(&dev->kobj), "%s", "queue");
if (ret < 0) {
blk_trace_remove_sysfs(dev);
+ kobject_put(&dev->kobj);
goto unlock;
}
--
1.9.1
next reply other threads:[~2019-06-03 7:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-03 7:46 Lin Yi [this message]
2019-06-03 14:55 ` [PATCH] block :blk-sysfs: fix refcount imbalance on the error path Bart Van Assche
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=20190603074653.GA12767@163.com \
--to=teroincn@163.com \
--cc=axboe@kernel.dk \
--cc=csong@cs.ucr.edu \
--cc=linux-block@vger.kernel.org \
--cc=liujian6@iie.ac.cn \
--cc=yiqiuping@gmail.com \
--cc=zhiyunq@cs.ucr.edu \
/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).