Skip to content

Commit

Permalink
block: drop device references in bsg_queue_rq()
Browse files Browse the repository at this point in the history
Make sure that bsg_queue_rq() calls put_device() if an error is
encountered after get_device() was successful.

Fixes: cd2f076 ("bsg: convert to use blk-mq")
Signed-off-by: Martin Wilck <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
mwilck authored and axboe committed Sep 23, 2019
1 parent be21683 commit d46fe2c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions block/bsg-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ static blk_status_t bsg_queue_rq(struct blk_mq_hw_ctx *hctx,
struct request *req = bd->rq;
struct bsg_set *bset =
container_of(q->tag_set, struct bsg_set, tag_set);
int sts = BLK_STS_IOERR;
int ret;

blk_mq_start_request(req);
Expand All @@ -274,14 +275,15 @@ static blk_status_t bsg_queue_rq(struct blk_mq_hw_ctx *hctx,
return BLK_STS_IOERR;

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;
if (!ret)
sts = BLK_STS_OK;

out:
put_device(dev);
return BLK_STS_OK;
return sts;
}

/* called right after the request is allocated for the request_queue */
Expand Down

0 comments on commit d46fe2c

Please sign in to comment.