Commit 7826810f authored by Li Lingfeng's avatar Li Lingfeng
Browse files

scsi: don't fail if hostt->module is NULL

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: default avatarLi Lingfeng <lilingfeng3@huawei.com>
parent 9f17b21a
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;
+1 −1
Original line number Diff line number Diff line
@@ -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;

+2 −0
Original line number Diff line number Diff line
@@ -698,6 +698,8 @@ struct Scsi_Host {
	 */
	struct device *dma_dev;

	bool is_builtin;

	KABI_RESERVE(1)
	KABI_RESERVE(2)
	KABI_RESERVE(3)