summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Grover <agrover@redhat.com>2015-05-22 14:07:44 -0700
committerBen Hutchings <ben@decadent.org.uk>2015-08-07 00:32:13 +0100
commit48793a2e5abc126a6446d8497c2117489622e9db (patch)
tree035b69f550f8bc2d12e6b1cf6fbf04d0268da8dd
parent7a1cc643ca060a2f6506f7c94c4c46f865a7726f (diff)
downloadlwn-48793a2e5abc126a6446d8497c2117489622e9db.tar.gz
lwn-48793a2e5abc126a6446d8497c2117489622e9db.zip
target/pscsi: Don't leak scsi_host if hba is VIRTUAL_HOST
commit 5a7125c64def3b21f8147eca8b54949a60963942 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: Andy Grover <agrover@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> [bwh: Backported to 3.2: adjust context] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--drivers/target/target_core_pscsi.c3
-rw-r--r--drivers/target/target_core_pscsi.h1
2 files changed, 4 insertions, 0 deletions
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index ebf9b600a58d..1fb9e5898953 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -569,6 +569,7 @@ static struct se_device *pscsi_create_virtdevice(
" pdv_host_id: %d\n", pdv->pdv_host_id);
return ERR_PTR(-EINVAL);
}
+ pdv->pdv_lld_host = sh;
}
} else {
if (phv->phv_mode == PHV_VIRUTAL_HOST_ID) {
@@ -655,6 +656,8 @@ static void pscsi_free_device(void *p)
if ((phv->phv_mode == PHV_LLD_SCSI_HOST_NO) &&
(phv->phv_lld_host != NULL))
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))
scsi_device_put(sd);
diff --git a/drivers/target/target_core_pscsi.h b/drivers/target/target_core_pscsi.h
index fdc17b6aefb3..8b0a3369dc9f 100644
--- a/drivers/target/target_core_pscsi.h
+++ b/drivers/target/target_core_pscsi.h
@@ -46,6 +46,7 @@ struct pscsi_dev_virt {
struct block_device *pdv_bd;
struct scsi_device *pdv_sd;
struct se_hba *pdv_se_hba;
+ struct Scsi_Host *pdv_lld_host;
} ____cacheline_aligned;
typedef enum phv_modes {