diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 18321cf9db5d69268a9fa5235ff588bf5c90031e..5bac4936c6474967f50b83214c65ac416ec6b1de 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 b6a384cb6b881b0e438b70b90f46914c7cbd9a3f..57b0dc08afeb45e8e20e1d5027af86c936e89fc9 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 && !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 19f595b6a5ca06ceea30a2aceeb64bd439d365cb..161d3d078ec9098ecd9e50bdeddb96984404bf89 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -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)