public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Tomas Henzl <thenzl@redhat.com>
To: Maurizio Lombardi <mlombard@redhat.com>, jayamohan.kallickal@emulex.com
Cc: linux-scsi@vger.kernel.org, michaelc@cs.wisc.edu,
	hch@infradead.org, JBottomley@parallels.com
Subject: Re: [PATCH] b2iscsi: Fix memory leak in mgmt_set_ip()
Date: Fri, 27 Jun 2014 18:32:10 +0200	[thread overview]
Message-ID: <53AD9C8A.7010007@redhat.com> (raw)
In-Reply-To: <1403873720-9642-1-git-send-email-mlombard@redhat.com>

On 06/27/2014 02:55 PM, Maurizio Lombardi wrote:
> The if_info pointer is not released by the mgmt_set_ip() function
>
> Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
> ---
>  drivers/scsi/be2iscsi/be_mgmt.c | 20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
> index 07934b0..a3e5648 100644
> --- a/drivers/scsi/be2iscsi/be_mgmt.c
> +++ b/drivers/scsi/be2iscsi/be_mgmt.c
> @@ -1015,7 +1015,7 @@ int mgmt_set_ip(struct beiscsi_hba *phba,
>  		if (if_info->dhcp_state) {
>  			beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
>  				    "BG_%d : DHCP Already Enabled\n");
> -			return 0;
> +			goto exit;

rc should be initialised - so this needs to be added to your patch
Cheers, Tomas
@@ -955,7 +955,7 @@ int mgmt_set_ip(struct beiscsi_hba *phba,
 	struct be_dma_mem nonemb_cmd;
 	uint8_t *gtway_addr;
 	uint32_t ip_type;
-	int rc;
+	int rc = 0;
 
 	if (mgmt_get_all_if_id(phba))
 		return -EIO;

>  		}
>  		/* The ip_param->len is 1 in DHCP case. Setting
>  		   proper IP len as this it is used while
> @@ -1033,7 +1033,7 @@ int mgmt_set_ip(struct beiscsi_hba *phba,
>  				sizeof(*reldhcp));
>  
>  			if (rc)
> -				return rc;
> +				goto exit;
>  
>  			reldhcp = nonemb_cmd.va;
>  			reldhcp->interface_hndl = phba->interface_handle;
> @@ -1044,7 +1044,7 @@ int mgmt_set_ip(struct beiscsi_hba *phba,
>  				beiscsi_log(phba, KERN_WARNING,
>  					    BEISCSI_LOG_CONFIG,
>  					    "BG_%d : Failed to Delete existing dhcp\n");
> -				return rc;
> +				goto exit;
>  			}
>  		}
>  	}
> @@ -1054,7 +1054,7 @@ int mgmt_set_ip(struct beiscsi_hba *phba,
>  		rc = mgmt_static_ip_modify(phba, if_info, ip_param, NULL,
>  					   IP_ACTION_DEL);
>  		if (rc)
> -			return rc;
> +			goto exit;
>  	}
>  
>  	/* Delete the Gateway settings if mode change is to DHCP */
> @@ -1064,7 +1064,7 @@ int mgmt_set_ip(struct beiscsi_hba *phba,
>  		if (rc) {
>  			beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
>  				    "BG_%d : Failed to Get Gateway Addr\n");
> -			return rc;
> +			goto exit;
>  		}
>  
>  		if (gtway_addr_set.ip_addr.addr[0]) {
> @@ -1076,7 +1076,7 @@ int mgmt_set_ip(struct beiscsi_hba *phba,
>  				beiscsi_log(phba, KERN_WARNING,
>  					    BEISCSI_LOG_CONFIG,
>  					    "BG_%d : Failed to clear Gateway Addr Set\n");
> -				return rc;
> +				goto exit;
>  			}
>  		}
>  	}
> @@ -1087,7 +1087,7 @@ int mgmt_set_ip(struct beiscsi_hba *phba,
>  			OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR,
>  			sizeof(*dhcpreq));
>  		if (rc)
> -			return rc;
> +			goto exit;
>  
>  		dhcpreq = nonemb_cmd.va;
>  		dhcpreq->flags = BLOCKING;
> @@ -1095,12 +1095,14 @@ int mgmt_set_ip(struct beiscsi_hba *phba,
>  		dhcpreq->interface_hndl = phba->interface_handle;
>  		dhcpreq->ip_type = BE2_DHCP_V4;
>  
> -		return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0);
> +		rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0);
>  	} else {
> -		return mgmt_static_ip_modify(phba, if_info, ip_param,
> +		rc = mgmt_static_ip_modify(phba, if_info, ip_param,
>  					     subnet_param, IP_ACTION_ADD);
>  	}
>  
> +exit:
> +	kfree(if_info);
>  	return rc;
>  }
>  


  reply	other threads:[~2014-06-27 18:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-27 12:55 [PATCH] b2iscsi: Fix memory leak in mgmt_set_ip() Maurizio Lombardi
2014-06-27 16:32 ` Tomas Henzl [this message]
2014-06-27 19:38   ` Maurizio Lombardi
2014-06-29 18:28     ` Tomas Henzl
2014-07-01 18:53       ` Christoph Hellwig
2014-07-07 11:29         ` Tomas Henzl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53AD9C8A.7010007@redhat.com \
    --to=thenzl@redhat.com \
    --cc=JBottomley@parallels.com \
    --cc=hch@infradead.org \
    --cc=jayamohan.kallickal@emulex.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=michaelc@cs.wisc.edu \
    --cc=mlombard@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox