Unverified Commit 934ede62 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!3152 scsi: scsi_device_gets returns failure

Merge Pull Request from: @ci-robot 
 
PR sync from: Li Lingfeng <lilingfeng3@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/KYEPL4QWKS2NEACHXVDEWEQDFQWBQBSH/ 
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.


-- 
2.31.1
 
https://gitee.com/openeuler/kernel/issues/I7YWV4 
 
Link:https://gitee.com/openeuler/kernel/pulls/3152

 

Reviewed-by: default avatarYu Kuai <yukuai3@huawei.com>
Reviewed-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents 8c17b6e2 e568427f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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;
+5 −1
Original line number Diff line number Diff line
@@ -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 && !sdev->host->is_builtin) || !try_module_get(module))
		goto fail_put_device;
	return 0;

+1 −1
Original line number Diff line number Diff line
@@ -698,7 +698,7 @@ struct Scsi_Host {
	 */
	struct device *dma_dev;

	KABI_RESERVE(1)
	KABI_USE(1, bool is_builtin)
	KABI_RESERVE(2)
	KABI_RESERVE(3)
	KABI_RESERVE(4)