diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 7150164c5ed95ea96e2524c8e8c02354bb999989..5299fa75215a96bbe35f32c5ff4f5302d35eca48 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -477,6 +477,9 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) shost->use_blk_mq = scsi_use_blk_mq || shost->hostt->force_blk_mq; + 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 acd118da88bfb50fc69917cb36bbcf863d1e5be1..6178b476bec6ea36ee8c29d9db81da472732191e 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -557,11 +557,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 29268cc34fe61a214db327ca9c58ab4638a2da0e..6382e92d1e274f33dd9a75d2fc6954682fe38270 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -710,7 +710,15 @@ struct Scsi_Host { */ struct device *dma_dev; + +#ifndef __GENKSYMS__ + union { + bool is_builtin; + KABI_RESERVE(1) + }; +#else KABI_RESERVE(1) +#endif KABI_RESERVE(2) KABI_RESERVE(3) KABI_RESERVE(4)