* [PATCH] lpfc: avoid double free of resource identifiers
@ 2017-01-11 10:06 Johannes Thumshirn
2017-01-11 19:47 ` James Smart
2017-01-12 3:57 ` Martin K. Petersen
0 siblings, 2 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2017-01-11 10:06 UTC (permalink / raw)
To: Martin K . Petersen
Cc: Linux SCSI Mailinglist, Linux Kernel Mailinglist, Dick Kennedy,
Roberto Sassu, Johannes Thumshirn
From: Roberto Sassu <rsassu@suse.de>
Set variables initialized in lpfc_sli4_alloc_resource_identifiers() to NULL
if an error occurred. Otherwise, lpfc_sli4_driver_resource_unset() attempts
to free the memory again.
Signed-off-by: Roberto Sassu <rsassu@suse.de>
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
drivers/scsi/lpfc/lpfc_sli.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 4faa767..a78a3df 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -5954,18 +5954,25 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba)
free_vfi_bmask:
kfree(phba->sli4_hba.vfi_bmask);
+ phba->sli4_hba.vfi_bmask = NULL;
free_xri_ids:
kfree(phba->sli4_hba.xri_ids);
+ phba->sli4_hba.xri_ids = NULL;
free_xri_bmask:
kfree(phba->sli4_hba.xri_bmask);
+ phba->sli4_hba.xri_bmask = NULL;
free_vpi_ids:
kfree(phba->vpi_ids);
+ phba->vpi_ids = NULL;
free_vpi_bmask:
kfree(phba->vpi_bmask);
+ phba->vpi_bmask = NULL;
free_rpi_ids:
kfree(phba->sli4_hba.rpi_ids);
+ phba->sli4_hba.rpi_ids = NULL;
free_rpi_bmask:
kfree(phba->sli4_hba.rpi_bmask);
+ phba->sli4_hba.rpi_bmask = NULL;
err_exit:
return rc;
}
--
2.10.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] lpfc: avoid double free of resource identifiers
2017-01-11 10:06 [PATCH] lpfc: avoid double free of resource identifiers Johannes Thumshirn
@ 2017-01-11 19:47 ` James Smart
2017-01-12 3:57 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: James Smart @ 2017-01-11 19:47 UTC (permalink / raw)
To: Johannes Thumshirn, Martin K . Petersen
Cc: Linux SCSI Mailinglist, Linux Kernel Mailinglist, Dick Kennedy,
Roberto Sassu
looks good. Thanks
Signed-off-by: James Smart <james.smart@broadcom.com>
-- james
On 1/11/2017 2:06 AM, Johannes Thumshirn wrote:
> From: Roberto Sassu <rsassu@suse.de>
>
> Set variables initialized in lpfc_sli4_alloc_resource_identifiers() to NULL
> if an error occurred. Otherwise, lpfc_sli4_driver_resource_unset() attempts
> to free the memory again.
>
> Signed-off-by: Roberto Sassu <rsassu@suse.de>
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
> drivers/scsi/lpfc/lpfc_sli.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
> index 4faa767..a78a3df 100644
> --- a/drivers/scsi/lpfc/lpfc_sli.c
> +++ b/drivers/scsi/lpfc/lpfc_sli.c
> @@ -5954,18 +5954,25 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba)
>
> free_vfi_bmask:
> kfree(phba->sli4_hba.vfi_bmask);
> + phba->sli4_hba.vfi_bmask = NULL;
> free_xri_ids:
> kfree(phba->sli4_hba.xri_ids);
> + phba->sli4_hba.xri_ids = NULL;
> free_xri_bmask:
> kfree(phba->sli4_hba.xri_bmask);
> + phba->sli4_hba.xri_bmask = NULL;
> free_vpi_ids:
> kfree(phba->vpi_ids);
> + phba->vpi_ids = NULL;
> free_vpi_bmask:
> kfree(phba->vpi_bmask);
> + phba->vpi_bmask = NULL;
> free_rpi_ids:
> kfree(phba->sli4_hba.rpi_ids);
> + phba->sli4_hba.rpi_ids = NULL;
> free_rpi_bmask:
> kfree(phba->sli4_hba.rpi_bmask);
> + phba->sli4_hba.rpi_bmask = NULL;
> err_exit:
> return rc;
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] lpfc: avoid double free of resource identifiers
2017-01-11 10:06 [PATCH] lpfc: avoid double free of resource identifiers Johannes Thumshirn
2017-01-11 19:47 ` James Smart
@ 2017-01-12 3:57 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2017-01-12 3:57 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: Martin K . Petersen, Linux SCSI Mailinglist,
Linux Kernel Mailinglist, Dick Kennedy, Roberto Sassu
>>>>> "Johannes" == Johannes Thumshirn <jthumshirn@suse.de> writes:
Johannes> Set variables initialized in
Johannes> lpfc_sli4_alloc_resource_identifiers() to NULL if an error
Johannes> occurred. Otherwise, lpfc_sli4_driver_resource_unset()
Johannes> attempts to free the memory again.
Applied to 4.10/scsi-fixes.
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-01-12 3:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-11 10:06 [PATCH] lpfc: avoid double free of resource identifiers Johannes Thumshirn
2017-01-11 19:47 ` James Smart
2017-01-12 3:57 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).