diff options
author | Martin Wilck <mwilck@suse.com> | 2019-09-23 10:02:02 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2019-09-23 13:17:24 -0400 |
commit | d46fe2cb2dce7f5038473b5859e03f5e16b7428e (patch) | |
tree | 408e14effb0c002d652c057826fd0f0f1c25805e /block/bsg-lib.c | |
parent | be21683e48f26032199504fb60b9a27eeff05fc3 (diff) |
block: drop device references in bsg_queue_rq()
Make sure that bsg_queue_rq() calls put_device() if an error is
encountered after get_device() was successful.
Fixes: cd2f076f1d7a ("bsg: convert to use blk-mq")
Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/bsg-lib.c')
-rw-r--r-- | block/bsg-lib.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/block/bsg-lib.c b/block/bsg-lib.c index 785dd58947f1..347dda16c2f4 100644 --- a/block/bsg-lib.c +++ b/block/bsg-lib.c | |||
@@ -266,6 +266,7 @@ static blk_status_t bsg_queue_rq(struct blk_mq_hw_ctx *hctx, | |||
266 | struct request *req = bd->rq; | 266 | struct request *req = bd->rq; |
267 | struct bsg_set *bset = | 267 | struct bsg_set *bset = |
268 | container_of(q->tag_set, struct bsg_set, tag_set); | 268 | container_of(q->tag_set, struct bsg_set, tag_set); |
269 | int sts = BLK_STS_IOERR; | ||
269 | int ret; | 270 | int ret; |
270 | 271 | ||
271 | blk_mq_start_request(req); | 272 | blk_mq_start_request(req); |
@@ -274,14 +275,15 @@ static blk_status_t bsg_queue_rq(struct blk_mq_hw_ctx *hctx, | |||
274 | return BLK_STS_IOERR; | 275 | return BLK_STS_IOERR; |
275 | 276 | ||
276 | if (!bsg_prepare_job(dev, req)) | 277 | if (!bsg_prepare_job(dev, req)) |
277 | return BLK_STS_IOERR; | 278 | goto out; |
278 | 279 | ||
279 | ret = bset->job_fn(blk_mq_rq_to_pdu(req)); | 280 | ret = bset->job_fn(blk_mq_rq_to_pdu(req)); |
280 | if (ret) | 281 | if (!ret) |
281 | return BLK_STS_IOERR; | 282 | sts = BLK_STS_OK; |
282 | 283 | ||
284 | out: | ||
283 | put_device(dev); | 285 | put_device(dev); |
284 | return BLK_STS_OK; | 286 | return sts; |
285 | } | 287 | } |
286 | 288 | ||
287 | /* called right after the request is allocated for the request_queue */ | 289 | /* called right after the request is allocated for the request_queue */ |