
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7YWV4 CVE: NA -------------------------------- If CONFIG_SCSI_VIRTIO is set as "y", sdev->host->hostt->module will be NULL, which means scsi device can't be probed normally. Fix the problem by adding a member in struct Scsi_Host to record whether the module is builtin. Fixes: 3f4659e76aa3 ("[Huawei] scsi: scsi_device_gets returns failure when the module is NULL.") Signed-off-by: Li Lingfeng <lilingfeng3@huawei.com> --- drivers/scsi/hosts.c | 3 +++ drivers/scsi/scsi.c | 2 +- include/scsi/scsi_host.h | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 18321cf9db5d..5bac4936c647 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -476,6 +476,9 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) if (sht->virt_boundary_mask) shost->virt_boundary_mask = sht->virt_boundary_mask; + if (!sht->module) + shost->is_builtin = true; + device_initialize(&shost->shost_gendev); dev_set_name(&shost->shost_gendev, "host%d", shost->host_no); shost->shost_gendev.bus = &scsi_bus_type; diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 6410482ade6f..57b0dc08afeb 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -537,7 +537,7 @@ int scsi_device_get(struct scsi_device *sdev) goto fail; module = sdev->host->hostt->module; - if (!module || !try_module_get(module)) + if ((!module && !sdev->host->is_builtin) || !try_module_get(module)) goto fail_put_device; return 0; diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 19f595b6a5ca..3a996be67fe5 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -698,6 +698,8 @@ struct Scsi_Host { */ struct device *dma_dev; + bool is_builtin; + KABI_RESERVE(1) KABI_RESERVE(2) KABI_RESERVE(3) -- 2.31.1