Unverified Commit 2ff2495d authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!3185 [sync] PR-3152: scsi: scsi_device_gets returns failure

Merge Pull Request from: @openeuler-sync-bot 
 

Origin pull request: 
https://gitee.com/openeuler/kernel/pulls/3152 
 
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/3185

 

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 3e88c820 4cad6383
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -477,6 +477,9 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
	if (sht->virt_boundary_mask)
	if (sht->virt_boundary_mask)
		shost->virt_boundary_mask = sht->virt_boundary_mask;
		shost->virt_boundary_mask = sht->virt_boundary_mask;


	if (!sht->module)
		shost->is_builtin = true;

	device_initialize(&shost->shost_gendev);
	device_initialize(&shost->shost_gendev);
	dev_set_name(&shost->shost_gendev, "host%d", shost->host_no);
	dev_set_name(&shost->shost_gendev, "host%d", shost->host_no);
	shost->shost_gendev.bus = &scsi_bus_type;
	shost->shost_gendev.bus = &scsi_bus_type;
+5 −1
Original line number Original line Diff line number Diff line
@@ -522,11 +522,15 @@ EXPORT_SYMBOL(scsi_report_opcode);
 */
 */
int scsi_device_get(struct scsi_device *sdev)
int scsi_device_get(struct scsi_device *sdev)
{
{
	struct module *module;

	if (sdev->sdev_state == SDEV_DEL || sdev->sdev_state == SDEV_CANCEL)
	if (sdev->sdev_state == SDEV_DEL || sdev->sdev_state == SDEV_CANCEL)
		goto fail;
		goto fail;
	if (!get_device(&sdev->sdev_gendev))
	if (!get_device(&sdev->sdev_gendev))
		goto fail;
		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;
		goto fail_put_device;
	return 0;
	return 0;


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


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