Skip to content

Commit

Permalink
bsg: free the request before return error code
Browse files Browse the repository at this point in the history
[ Upstream commit 0f7b4bc ]

Free the request rq before returning error code.

Fixes: 972248e ("scsi: bsg-lib: handle bidi requests without block layer help")
Signed-off-by: Pan Bian <bianpan2016@163.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
SinkFinder authored and gregkh committed Mar 4, 2021
1 parent b720e3d commit db10f33
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion block/bsg.c
Expand Up @@ -157,8 +157,10 @@ static int bsg_sg_io(struct request_queue *q, fmode_t mode, void __user *uarg)
return PTR_ERR(rq);

ret = q->bsg_dev.ops->fill_hdr(rq, &hdr, mode);
if (ret)
if (ret) {
blk_put_request(rq);
return ret;
}

rq->timeout = msecs_to_jiffies(hdr.timeout);
if (!rq->timeout)
Expand Down

0 comments on commit db10f33

Please sign in to comment.