diff mbox series

[v5,7/7] scsi: core: Improve SCSI device removal

Message ID 20220914225621.415631-8-bvanassche@acm.org
State New
Headers show
Series Prepare for constifying SCSI host templates | expand

Commit Message

Bart Van Assche Sept. 14, 2022, 10:56 p.m. UTC
Instead of clearing the host template module pointer if the LLD kernel
module is being unloaded, call __module_get() unconditionally. This
patch is a bug fix because it prevents that a SCSI LLD is unloaded after
scsi_device_dev_release() returns and before
scsi_device_dev_release_usercontext() is called.

Suggested-by: Christoph Hellwig <hch@lst.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: John Garry <john.garry@huawei.com>
Cc: Mike Christie <michael.christie@oracle.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi_sysfs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index a3aaafdeac1d..661c2bdd4588 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -523,9 +523,7 @@  static void scsi_device_dev_release(struct device *dev)
 {
 	struct scsi_device *sdp = to_scsi_device(dev);
 
-	/* Set module pointer as NULL in case of module unloading */
-	if (!try_module_get(sdp->host->hostt->module))
-		sdp->host->hostt->module = NULL;
+	__module_get(sdp->host->hostt->module);
 
 	execute_in_process_context(scsi_device_dev_release_usercontext,
 				   &sdp->ew);