From: Zhong Jinghua zhongjinghua@huawei.com
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7YWV4 CVE: NA
--------------------------------
when module is NULL, try_module_get return true. But it would be better to return failure in scsi_device_get.
Signed-off-by: Zhong Jinghua zhongjinghua@huawei.com Signed-off-by: Li Lingfeng lilingfeng3@huawei.com --- drivers/scsi/scsi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index b6a384cb6b88..6410482ade6f 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -529,11 +529,15 @@ EXPORT_SYMBOL(scsi_report_opcode); */ int scsi_device_get(struct scsi_device *sdev) { + struct module *module; + if (sdev->sdev_state == SDEV_DEL || sdev->sdev_state == SDEV_CANCEL) goto fail; if (!get_device(&sdev->sdev_gendev)) goto fail; - if (!try_module_get(sdev->host->hostt->module)) + + module = sdev->host->hostt->module; + if (!module || !try_module_get(module)) goto fail_put_device; return 0;