scsi: core: Only put parent device if host state differs from SHOST_CREATED
authorMing Lei <ming.lei@redhat.com>
Wed, 2 Jun 2021 13:30:29 +0000 (21:30 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 8 Jun 2021 02:12:44 +0000 (22:12 -0400)
get_device(shost->shost_gendev.parent) is called after host state has
switched to SHOST_RUNNING. scsi_host_dev_release() shouldn't release the
parent device if host state is still SHOST_CREATED.

Link: https://lore.kernel.org/r/20210602133029.2864069-5-ming.lei@redhat.com
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: John Garry <john.garry@huawei.com>
Cc: Hannes Reinecke <hare@suse.de>
Tested-by: John Garry <john.garry@huawei.com>
Reviewed-by: John Garry <john.garry@huawei.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/hosts.c

index 7627a1e1f41abdd9195805c003bb217d5373b9ae..cd52664920e1aa17c49d3b491b50a4a58d2af24b 100644 (file)
@@ -347,7 +347,7 @@ static void scsi_host_dev_release(struct device *dev)
 
        ida_simple_remove(&host_index_ida, shost->host_no);
 
-       if (parent)
+       if (shost->shost_state != SHOST_CREATED)
                put_device(parent);
        kfree(shost);
 }