]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
scsi: core: Put .shost_dev in failure path if host state changes to RUNNING
authorMing Lei <ming.lei@redhat.com>
Wed, 2 Jun 2021 13:30:28 +0000 (21:30 +0800)
committerSasha Levin <sashal@kernel.org>
Wed, 30 Jun 2021 12:49:34 +0000 (08:49 -0400)
commitfbedbc8fb1dc2bc0545523ff6d6792d697a17ba9
tree7abbdd180fec02b7e6df81a1ab4eeb83112cc32d
parentdb2bc3cfd2bc01621014d4f17cdfc74611f339c8
scsi: core: Put .shost_dev in failure path if host state changes to RUNNING

[ Upstream commit 11714026c02d613c30a149c3f4c4a15047744529 ]

scsi_host_dev_release() only frees dev_name when host state is
SHOST_CREATED. After host state has changed to SHOST_RUNNING,
scsi_host_dev_release() no longer cleans up.

Fix this by doing a put_device(&shost->shost_dev) in the failure path when
host state is SHOST_RUNNING. Move get_device(&shost->shost_gendev) before
device_add(&shost->shost_dev) so that scsi_host_cls_release() can do a put
on this reference.

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