From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: [PATCH] blk-mq: Fix refcounting leak in __blk_mq_register_dev()
Date: Sat, 5 Sep 2020 15:52:06 +0300 [thread overview]
Message-ID: <20200905125206.GE183976@mwanda> (raw)
There is a kobject_add() hidden in the call to kobject_add().
ret = kobject_add(q->mq_kobj, kobject_get(&dev->kobj), "%s", "mq");
^^^^^^^^^^^^^^^^^^^^^^^
It needs to be release on the error path.
Fixes: 320ae51feed5 ("blk-mq: new multi-queue block IO queueing mechanism")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
block/blk-mq-sysfs.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
index 062229395a50..5a63659163c1 100644
--- a/block/blk-mq-sysfs.c
+++ b/block/blk-mq-sysfs.c
@@ -321,7 +321,7 @@ int __blk_mq_register_dev(struct device *dev, struct request_queue *q)
ret = kobject_add(q->mq_kobj, kobject_get(&dev->kobj), "%s", "mq");
if (ret < 0)
- goto out;
+ goto out_kobj;
kobject_uevent(q->mq_kobj, KOBJ_ADD);
@@ -333,8 +333,7 @@ int __blk_mq_register_dev(struct device *dev, struct request_queue *q)
q->mq_sysfs_init_done = true;
-out:
- return ret;
+ return 0;
unreg:
while (--i >= 0)
@@ -342,6 +341,7 @@ int __blk_mq_register_dev(struct device *dev, struct request_queue *q)
kobject_uevent(q->mq_kobj, KOBJ_REMOVE);
kobject_del(q->mq_kobj);
+out_kobj:
kobject_put(&dev->kobj);
return ret;
}
--
2.28.0
next reply other threads:[~2020-09-05 12:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-05 12:52 Dan Carpenter [this message]
2020-09-07 7:19 ` [PATCH] blk-mq: Fix refcounting leak in __blk_mq_register_dev() Ming Lei
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=20200905125206.GE183976@mwanda \
--to=dan.carpenter@oracle.com \
--cc=axboe@kernel.dk \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@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