]> git.baikalelectronics.ru Git - kernel.git/commitdiff
bsg: free the request before return error code
authorPan Bian <bianpan2016@163.com>
Tue, 19 Jan 2021 12:33:11 +0000 (04:33 -0800)
committerJens Axboe <axboe@kernel.dk>
Mon, 25 Jan 2021 04:36:41 +0000 (21:36 -0700)
Free the request rq before returning error code.

Fixes: e23b90c14fa3 ("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>
block/bsg.c

index d7bae94b64d95b96cdde1e1ce89543f839f83954..3d78e843a83f65469c0eeb19ebea9c28a06d2529 100644 (file)
@@ -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)