summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/scsi.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index eedfd059b82b..c35f5fc0d668 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -873,10 +873,12 @@ EXPORT_SYMBOL(scsi_device_get);
*/
void scsi_device_put(struct scsi_device *sdev)
{
+ struct module *module = sdev->host->hostt->module;
+
/* The module refcount will be zero if scsi_device_get()
* was called from a module removal routine */
- if (likely(module_refcount(sdev->host->hostt->module) != 0))
- module_put(sdev->host->hostt->module);
+ if (module && module_refcount(module) != 0)
+ module_put(module);
put_device(&sdev->sdev_gendev);
}
EXPORT_SYMBOL(scsi_device_put);