lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 17 Apr 2019 11:11:55 +0800
From:   Pan Bian <bianpan2016@....com>
To:     Jens Axboe <axboe@...nel.dk>
Cc:     linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
        Pan Bian <bianpan2016@....com>
Subject: scsi: bsg-lib: drop device reference on error path

The function put_device is not called to drop the device reference taken
by get_device on error paths. This patch fixes the bug.

Fixes: cd2f076f1d7("bsg: convert to use blk-mq")
Signed-off-by: Pan Bian <bianpan2016@....com>
---
 block/bsg-lib.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/block/bsg-lib.c b/block/bsg-lib.c
index 005e2b7..fe9e0cc 100644
--- a/block/bsg-lib.c
+++ b/block/bsg-lib.c
@@ -281,21 +281,24 @@ static blk_status_t bsg_queue_rq(struct blk_mq_hw_ctx *hctx,
 	struct bsg_set *bset =
 		container_of(q->tag_set, struct bsg_set, tag_set);
 	int ret;
+	blk_status_t status = BLK_STS_IOERR;
 
 	blk_mq_start_request(req);
 
 	if (!get_device(dev))
-		return BLK_STS_IOERR;
+		return status;
 
 	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;
+		goto out;
 
+	status = BLK_STS_OK;
+out:
 	put_device(dev);
-	return BLK_STS_OK;
+	return status;
 }
 
 /* called right after the request is allocated for the request_queue */
-- 
2.7.4


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ