diff options
| author | Andy Grover <agrover@redhat.com> | 2015-05-22 17:07:44 -0400 |
|---|---|---|
| committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2015-05-30 22:11:02 -0400 |
| commit | 5a7125c64def3b21f8147eca8b54949a60963942 (patch) | |
| tree | a89c0e0848ddc548058a698d80cd245946fbe336 /drivers/target | |
| parent | d588cf8f618d7b316743a0bc99fede20f7a01bb7 (diff) | |
target/pscsi: Don't leak scsi_host if hba is VIRTUAL_HOST
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>
Cc: stable@vger.kernel.org # 2.6.38+
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
| -rw-r--r-- | drivers/target/target_core_pscsi.c | 3 | ||||
| -rw-r--r-- | drivers/target/target_core_pscsi.h | 1 |
2 files changed, 4 insertions, 0 deletions
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c index f6c954c4635f..4073869d2090 100644 --- a/drivers/target/target_core_pscsi.c +++ b/drivers/target/target_core_pscsi.c | |||
| @@ -521,6 +521,7 @@ static int pscsi_configure_device(struct se_device *dev) | |||
| 521 | " pdv_host_id: %d\n", pdv->pdv_host_id); | 521 | " pdv_host_id: %d\n", pdv->pdv_host_id); |
| 522 | return -EINVAL; | 522 | return -EINVAL; |
| 523 | } | 523 | } |
| 524 | pdv->pdv_lld_host = sh; | ||
| 524 | } | 525 | } |
| 525 | } else { | 526 | } else { |
| 526 | if (phv->phv_mode == PHV_VIRTUAL_HOST_ID) { | 527 | if (phv->phv_mode == PHV_VIRTUAL_HOST_ID) { |
| @@ -603,6 +604,8 @@ static void pscsi_free_device(struct se_device *dev) | |||
| 603 | if ((phv->phv_mode == PHV_LLD_SCSI_HOST_NO) && | 604 | if ((phv->phv_mode == PHV_LLD_SCSI_HOST_NO) && |
| 604 | (phv->phv_lld_host != NULL)) | 605 | (phv->phv_lld_host != NULL)) |
| 605 | scsi_host_put(phv->phv_lld_host); | 606 | scsi_host_put(phv->phv_lld_host); |
| 607 | else if (pdv->pdv_lld_host) | ||
| 608 | scsi_host_put(pdv->pdv_lld_host); | ||
| 606 | 609 | ||
| 607 | if ((sd->type == TYPE_DISK) || (sd->type == TYPE_ROM)) | 610 | if ((sd->type == TYPE_DISK) || (sd->type == TYPE_ROM)) |
| 608 | scsi_device_put(sd); | 611 | scsi_device_put(sd); |
diff --git a/drivers/target/target_core_pscsi.h b/drivers/target/target_core_pscsi.h index 1bd757dff8ee..820d3052b775 100644 --- a/drivers/target/target_core_pscsi.h +++ b/drivers/target/target_core_pscsi.h | |||
| @@ -45,6 +45,7 @@ struct pscsi_dev_virt { | |||
| 45 | int pdv_lun_id; | 45 | int pdv_lun_id; |
| 46 | struct block_device *pdv_bd; | 46 | struct block_device *pdv_bd; |
| 47 | struct scsi_device *pdv_sd; | 47 | struct scsi_device *pdv_sd; |
| 48 | struct Scsi_Host *pdv_lld_host; | ||
| 48 | } ____cacheline_aligned; | 49 | } ____cacheline_aligned; |
| 49 | 50 | ||
| 50 | typedef enum phv_modes { | 51 | typedef enum phv_modes { |
