
hulk inclusion category: bugfix bugzilla: 189103, 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> --- 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 f561caabc771..1a81c8198e44 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -522,11 +522,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; -- 2.31.1