diff mbox series

[1/1] bsg: free the request before return error code

Message ID 20210119123311.108137-1-bianpan2016@163.com (mailing list archive)
State Not Applicable
Headers show
Series [1/1] bsg: free the request before return error code | expand

Commit Message

Pan Bian Jan. 19, 2021, 12:33 p.m. UTC
Free the request rq before returning error code.

Fixes: 972248e9111e ("scsi: bsg-lib: handle bidi requests without block layer help")
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 block/bsg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Christoph Hellwig Jan. 20, 2021, 9:52 a.m. UTC | #1
On Tue, Jan 19, 2021 at 04:33:11AM -0800, Pan Bian wrote:
> Free the request rq before returning error code.
> 
> Fixes: 972248e9111e ("scsi: bsg-lib: handle bidi requests without block layer help")
> Signed-off-by: Pan Bian <bianpan2016@163.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
Jens Axboe Jan. 25, 2021, 4:36 a.m. UTC | #2
On 1/19/21 5:33 AM, Pan Bian wrote:
> Free the request rq before returning error code.

Applied, thanks.
diff mbox series

Patch

diff --git a/block/bsg.c b/block/bsg.c
index d7bae94b64d9..3d78e843a83f 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -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)