If scsi is compiled as a module, scsi_device_gets returns failure when the module is NULL.
Li Lingfeng (2): scsi: don't fail if hostt->module is NULL scsi: fix kabi broken in struct Scsi_Host
Zhong Jinghua (1): scsi: scsi_device_gets returns failure when the module is NULL.
drivers/scsi/hosts.c | 3 +++ drivers/scsi/scsi.c | 6 +++++- include/scsi/scsi_host.h | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-)
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;
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,转换为PR失败! 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/Z... 失败原因:补丁集缺失封面信息 建议解决方法:请提供补丁集并重新发送您的补丁集到邮件列表
FeedBack: The patch(es) which you have sent to kernel@openeuler.org has been converted to PR failed! Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/Z... Failed Reason: the cover of the patches is missing Suggest Solution: please checkout and apply the patches' cover and send all again
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)
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7YWV4 CVE: NA
--------------------------------
This broken caused by adding "is_builtin". Fix kabi broken in struct Scsi_Host.
Signed-off-by: Li Lingfeng lilingfeng3@huawei.com --- include/scsi/scsi_host.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 3a996be67fe5..161d3d078ec9 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -698,9 +698,7 @@ struct Scsi_Host { */ struct device *dma_dev;
- bool is_builtin; - - KABI_RESERVE(1) + KABI_USE(1, bool is_builtin) KABI_RESERVE(2) KABI_RESERVE(3) KABI_RESERVE(4)
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,转换为PR失败! 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/5... 失败原因:应用补丁/补丁集失败,Patch failed at 0004 scsi: scsi_device_gets returns failure when the module is NULL. 建议解决方法:请查看失败原因, 确认补丁是否可以应用在当前期望分支的最新代码上
FeedBack: The patch(es) which you have sent to kernel@openeuler.org has been converted to PR failed! Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/5... Failed Reason: apply patch(es) failed, Patch failed at 0004 scsi: scsi_device_gets returns failure when the module is NULL. Suggest Solution: please checkout if the failed patch(es) can work on the newest codes in expected branch