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 <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Yu Kuai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Tested-by: Shin'ichiro Kawasaki <[email protected]> Tested-by: Marc Hartmayer <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Marc Hartmayer <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
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)