From: Pan Bian <bianpan2016@163.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
Pan Bian <bianpan2016@163.com>
Subject: scsi: bsg-lib: drop device reference on error path
Date: Wed, 17 Apr 2019 11:11:55 +0800 [thread overview]
Message-ID: <1555470715-55702-1-git-send-email-bianpan2016@163.com> (raw)
The function put_device is not called to drop the device reference taken
by get_device on error paths. This patch fixes the bug.
Fixes: cd2f076f1d7("bsg: convert to use blk-mq")
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
block/bsg-lib.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/block/bsg-lib.c b/block/bsg-lib.c
index 005e2b7..fe9e0cc 100644
--- a/block/bsg-lib.c
+++ b/block/bsg-lib.c
@@ -281,21 +281,24 @@ static blk_status_t bsg_queue_rq(struct blk_mq_hw_ctx *hctx,
struct bsg_set *bset =
container_of(q->tag_set, struct bsg_set, tag_set);
int ret;
+ blk_status_t status = BLK_STS_IOERR;
blk_mq_start_request(req);
if (!get_device(dev))
- return BLK_STS_IOERR;
+ return status;
if (!bsg_prepare_job(dev, req))
- return BLK_STS_IOERR;
+ goto out;
ret = bset->job_fn(blk_mq_rq_to_pdu(req));
if (ret)
- return BLK_STS_IOERR;
+ goto out;
+ status = BLK_STS_OK;
+out:
put_device(dev);
- return BLK_STS_OK;
+ return status;
}
/* called right after the request is allocated for the request_queue */
--
2.7.4
next reply other threads:[~2019-04-17 3:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-17 3:11 Pan Bian [this message]
2019-04-17 9:18 ` scsi: bsg-lib: drop device reference on error path Chaitanya Kulkarni
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=1555470715-55702-1-git-send-email-bianpan2016@163.com \
--to=bianpan2016@163.com \
--cc=axboe@kernel.dk \
--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;
as well as URLs for NNTP newsgroup(s).