diff mbox

be2iscsi: Fix memory leak in beiscsi_alloc_mem()

Message ID 1443689785-13712-1-git-send-email-mlombard@redhat.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Maurizio Lombardi Oct. 1, 2015, 8:56 a.m. UTC
In case of error, the memory allocated for phwi_ctrlr was not freed.

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
---
 drivers/scsi/be2iscsi/be_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Maurizio Lombardi Feb. 10, 2016, 10:13 a.m. UTC | #1
ping.

On 10/01/2015 10:56 AM, Maurizio Lombardi wrote:
> In case of error, the memory allocated for phwi_ctrlr was not freed.
> 
> Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
> ---
>  drivers/scsi/be2iscsi/be_main.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
> index 7a6dbfb..360aa88 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -2706,8 +2706,10 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba)
>  	phwi_ctrlr->wrb_context = kzalloc(sizeof(struct hwi_wrb_context) *
>  					  phba->params.cxns_per_ctrl,
>  					  GFP_KERNEL);
> -	if (!phwi_ctrlr->wrb_context)
> +	if (!phwi_ctrlr->wrb_context) {
> +		kfree(phba->phwi_ctrlr);
>  		return -ENOMEM;
> +	}
>  
>  	phba->init_mem = kcalloc(SE_MEM_MAX, sizeof(*mem_descr),
>  				 GFP_KERNEL);
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Johannes Thumshirn Feb. 10, 2016, 11:07 a.m. UTC | #2
On Wed, Feb 10, 2016 at 11:13:39AM +0100, Maurizio Lombardi wrote:
> ping.
> 
> On 10/01/2015 10:56 AM, Maurizio Lombardi wrote:
> > In case of error, the memory allocated for phwi_ctrlr was not freed.
> > 
> > Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
> > ---
> >  drivers/scsi/be2iscsi/be_main.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
> > index 7a6dbfb..360aa88 100644
> > --- a/drivers/scsi/be2iscsi/be_main.c
> > +++ b/drivers/scsi/be2iscsi/be_main.c
> > @@ -2706,8 +2706,10 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba)
> >  	phwi_ctrlr->wrb_context = kzalloc(sizeof(struct hwi_wrb_context) *
> >  					  phba->params.cxns_per_ctrl,
> >  					  GFP_KERNEL);
> > -	if (!phwi_ctrlr->wrb_context)
> > +	if (!phwi_ctrlr->wrb_context) {
> > +		kfree(phba->phwi_ctrlr);
> >  		return -ENOMEM;
> > +	}
> >  
> >  	phba->init_mem = kcalloc(SE_MEM_MAX, sizeof(*mem_descr),
> >  				 GFP_KERNEL);
> > 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Martin K. Petersen Feb. 10, 2016, 5:23 p.m. UTC | #3
>>>>> "Maurizio" == Maurizio Lombardi <mlombard@redhat.com> writes:

Jitendra,

Please review.

> In case of error, the memory allocated for phwi_ctrlr was not freed.
> 
> Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
> ---
>  drivers/scsi/be2iscsi/be_main.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
> index 7a6dbfb..360aa88 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -2706,8 +2706,10 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba)
>  	phwi_ctrlr->wrb_context = kzalloc(sizeof(struct hwi_wrb_context) *
>  					  phba->params.cxns_per_ctrl,
>  					  GFP_KERNEL);
> -	if (!phwi_ctrlr->wrb_context)
> +	if (!phwi_ctrlr->wrb_context) {
> +		kfree(phba->phwi_ctrlr);
>  		return -ENOMEM;
> +	}
>  
>  	phba->init_mem = kcalloc(SE_MEM_MAX, sizeof(*mem_descr),
>  				 GFP_KERNEL);
>
diff mbox

Patch

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 7a6dbfb..360aa88 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -2706,8 +2706,10 @@  static int beiscsi_alloc_mem(struct beiscsi_hba *phba)
 	phwi_ctrlr->wrb_context = kzalloc(sizeof(struct hwi_wrb_context) *
 					  phba->params.cxns_per_ctrl,
 					  GFP_KERNEL);
-	if (!phwi_ctrlr->wrb_context)
+	if (!phwi_ctrlr->wrb_context) {
+		kfree(phba->phwi_ctrlr);
 		return -ENOMEM;
+	}
 
 	phba->init_mem = kcalloc(SE_MEM_MAX, sizeof(*mem_descr),
 				 GFP_KERNEL);