Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1556361 > unrolled thread

[PATCH] lpfc: avoid double free of resource identifiers

Started byJohannes Thumshirn <jthumshirn@suse.de>
First post2017-01-11 11:10 +0100
Last post2017-01-12 05:00 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] lpfc: avoid double free of resource identifiers Johannes Thumshirn <jthumshirn@suse.de> - 2017-01-11 11:10 +0100
    Re: [PATCH] lpfc: avoid double free of resource identifiers James Smart <james.smart@broadcom.com> - 2017-01-11 21:00 +0100
    Re: [PATCH] lpfc: avoid double free of resource identifiers "Martin K. Petersen" <martin.petersen@oracle.com> - 2017-01-12 05:00 +0100

#1556361 — [PATCH] lpfc: avoid double free of resource identifiers

FromJohannes Thumshirn <jthumshirn@suse.de>
Date2017-01-11 11:10 +0100
Subject[PATCH] lpfc: avoid double free of resource identifiers
Message-ID<sYo0W-5B1-35@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1556875

FromJames Smart <james.smart@broadcom.com>
Date2017-01-11 21:00 +0100
Message-ID<sYxdT-2C4-11@gated-at.bofh.it>
In reply to#1556361
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;
>   }

[toc] | [prev] | [next] | [standalone]


#1557110

From"Martin K. Petersen" <martin.petersen@oracle.com>
Date2017-01-12 05:00 +0100
Message-ID<sYEIp-7mE-3@gated-at.bofh.it>
In reply to#1556361
>>>>> "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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web