Commit 195fae20 authored by Bart Van Assche's avatar Bart Van Assche Committed by Martin K. Petersen

scsi: core: Remove the put_device() call from scsi_device_get()

scsi_device_get() may be called from atomic context, e.g. by
shost_for_each_device(). A later commit will allow put_device() to sleep
for SCSI devices. Hence remove the put_device() call from
scsi_device_get().

According to Rusty Russell's "Module Refcount and Stuff mini-FAQ", calling
module_put() from atomic context is allowed since considerable time. See
also https://lkml.org/lkml/2002/11/18/330.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Mike Christie <michael.christie@oracle.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20221015002418.30955-8-bvanassche@acm.orgSigned-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 6d1aa3b0
...@@ -563,14 +563,14 @@ int scsi_device_get(struct scsi_device *sdev) ...@@ -563,14 +563,14 @@ int scsi_device_get(struct scsi_device *sdev)
{ {
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))
goto fail;
if (!try_module_get(sdev->host->hostt->module)) if (!try_module_get(sdev->host->hostt->module))
goto fail_put_device; goto fail;
if (!get_device(&sdev->sdev_gendev))
goto fail_put_module;
return 0; return 0;
fail_put_device: fail_put_module:
put_device(&sdev->sdev_gendev); module_put(sdev->host->hostt->module);
fail: fail:
return -ENXIO; return -ENXIO;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment