Skip to content

Commit 80b6051

Browse files
YuKuai-huaweimartinkpetersen
authored andcommitted
scsi: sg: Fix checking return value of blk_get_queue()
Commit fcaa174 ("scsi/sg: don't grab scsi host module reference") make a mess how blk_get_queue() is called, blk_get_queue() returns true on success while the caller expects it returns 0 on success. Fix this problem and also add a corresponding error message on failure. Fixes: fcaa174 ("scsi/sg: don't grab scsi host module reference") Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com> Closes: https://lore.kernel.org/all/87lefv622n.fsf@linux.ibm.com/ Signed-off-by: Yu Kuai <yukuai3@huawei.com> Link: https://lore.kernel.org/r/20230705024001.177585-1-yukuai1@huaweicloud.com Tested-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> Tested-by: Marc Hartmayer <mhartmay@linux.ibm.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent f4d1a8e commit 80b6051

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/scsi/sg.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,9 +1497,10 @@ sg_add_device(struct device *cl_dev)
14971497
int error;
14981498
unsigned long iflags;
14991499

1500-
error = blk_get_queue(scsidp->request_queue);
1501-
if (error)
1502-
return error;
1500+
if (!blk_get_queue(scsidp->request_queue)) {
1501+
pr_warn("%s: get scsi_device queue failed\n", __func__);
1502+
return -ENODEV;
1503+
}
15031504

15041505
error = -ENOMEM;
15051506
cdev = cdev_alloc();

0 commit comments

Comments
 (0)