Commit 419985ec authored by Andy Grover's avatar Andy Grover Committed by Zefan Li

target/pscsi: Don't leak scsi_host if hba is VIRTUAL_HOST

commit 5a7125c6 upstream.

See https://bugzilla.redhat.com/show_bug.cgi?id=1025672

We need to put() the reference to the scsi host that we got in
pscsi_configure_device(). In VIRTUAL_HOST mode it is associated with
the dev_virt, not the hba_virt.
Signed-off-by: default avatarAndy Grover <agrover@redhat.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
[lizf: Backported to 3.4: adjust context]
Signed-off-by: default avatarZefan Li <lizefan@huawei.com>
parent 19cc68ff
...@@ -567,6 +567,7 @@ static struct se_device *pscsi_create_virtdevice( ...@@ -567,6 +567,7 @@ static struct se_device *pscsi_create_virtdevice(
" pdv_host_id: %d\n", pdv->pdv_host_id); " pdv_host_id: %d\n", pdv->pdv_host_id);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
pdv->pdv_lld_host = sh;
} }
} else { } else {
if (phv->phv_mode == PHV_VIRTUAL_HOST_ID) { if (phv->phv_mode == PHV_VIRTUAL_HOST_ID) {
...@@ -653,6 +654,8 @@ static void pscsi_free_device(void *p) ...@@ -653,6 +654,8 @@ static void pscsi_free_device(void *p)
if ((phv->phv_mode == PHV_LLD_SCSI_HOST_NO) && if ((phv->phv_mode == PHV_LLD_SCSI_HOST_NO) &&
(phv->phv_lld_host != NULL)) (phv->phv_lld_host != NULL))
scsi_host_put(phv->phv_lld_host); scsi_host_put(phv->phv_lld_host);
else if (pdv->pdv_lld_host)
scsi_host_put(pdv->pdv_lld_host);
if ((sd->type == TYPE_DISK) || (sd->type == TYPE_ROM)) if ((sd->type == TYPE_DISK) || (sd->type == TYPE_ROM))
scsi_device_put(sd); scsi_device_put(sd);
......
...@@ -45,6 +45,7 @@ struct pscsi_dev_virt { ...@@ -45,6 +45,7 @@ struct pscsi_dev_virt {
int pdv_lun_id; int pdv_lun_id;
struct block_device *pdv_bd; struct block_device *pdv_bd;
struct scsi_device *pdv_sd; struct scsi_device *pdv_sd;
struct Scsi_Host *pdv_lld_host;
struct se_hba *pdv_se_hba; struct se_hba *pdv_se_hba;
} ____cacheline_aligned; } ____cacheline_aligned;
......
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