Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: core: Put .shost_dev in failure path if host state changes to RUNNING

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>

authored by

Ming Lei and committed by
Martin K. Petersen
11714026 3719f4ff

+6 -2
+6 -2
drivers/scsi/hosts.c
··· 254 254 255 255 device_enable_async_suspend(&shost->shost_dev); 256 256 257 + get_device(&shost->shost_gendev); 257 258 error = device_add(&shost->shost_dev); 258 259 if (error) 259 260 goto out_del_gendev; 260 - 261 - get_device(&shost->shost_gendev); 262 261 263 262 if (shost->transportt->host_size) { 264 263 shost->shost_data = kzalloc(shost->transportt->host_size, ··· 296 297 out_del_dev: 297 298 device_del(&shost->shost_dev); 298 299 out_del_gendev: 300 + /* 301 + * Host state is SHOST_RUNNING so we have to explicitly release 302 + * ->shost_dev. 303 + */ 304 + put_device(&shost->shost_dev); 299 305 device_del(&shost->shost_gendev); 300 306 out_disable_runtime_pm: 301 307 device_disable_async_suspend(&shost->shost_gendev);