Skip to contentSkip to conversation

bsg: free the request before return error code

PATCH Applied Pan Bian 3 participants 3 messages Jan 19, 2021 – Jan 25, 2021

Subsystems (3)
lore
Share & tools
lore

Pan Bian

author
#0 lore raw

PATCH 1/1 bsg: free the request before return error code

Free the request rq before returning error code.

Fixes 972248e9111e ("scsi: bsg-lib: handle bidi requests without block layer help")
---
 block/bsg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
block/bsg.c +3 -1
index d7bae94b64d9..3d78e843a83f 100644
@@ -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)
Signature · 1 line
2.17.1
maintainer Applied
#2 lore raw
In reply to Pan Bian
Quoted 1 line · Pan Bian

Free the request rq before returning error code.

Applied, thanks.

Signature · 1 line
Jens Axboe