[PATCH] ctdb: Coverity fix for CID 1291643

Michael Adam obnox at samba.org
Tue Mar 31 09:11:57 MDT 2015


Reviewed-by: me

On 2015-03-31 at 09:59 -0400, Rajesh Joseph wrote:
> Hi all,
> 
> This is a fix for coverity bug CID 1291643. 
> Please review the patch and let me know if you have any comments.
> 
> Thanks & Regards,
> Rajesh

> From efb5fda2350b230efb7b2f69d529f476f33c9dc0 Mon Sep 17 00:00:00 2001
> From: Rajesh Joseph <rjoseph at redhat.com>
> Date: Tue, 31 Mar 2015 18:43:36 +0530
> Subject: [PATCH] ctdb: Coverity fix for CID 1291643
> 
> CID 1291643: Resource leak: leaked_handle: Handle
> variable lock_fd going out of scope leaks the handle.
> 
> Fix: on failure case release handle variable lock_fd
> 
> Signed-off-by: Rajesh Joseph <rjoseph at redhat.com>
> ---
>  ctdb/tcp/tcp_connect.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/ctdb/tcp/tcp_connect.c b/ctdb/tcp/tcp_connect.c
> index 6950ac8..78ad04b 100644
> --- a/ctdb/tcp/tcp_connect.c
> +++ b/ctdb/tcp/tcp_connect.c
> @@ -347,7 +347,11 @@ static int ctdb_tcp_listen_automatic(struct ctdb_context *ctdb)
>  	ctdb->address = talloc_memdup(ctdb,
>  				      &ctdb->nodes[i]->address,
>  				      sizeof(ctdb_sock_addr));
> -	CTDB_NO_MEMORY(ctdb, ctdb->address);
> +	if (NULL == ctdb->address) {
> +		DEBUG(DEBUG_ERR,("Out of memory for ctdb->address at %s\n", __location__));
> +		ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__);
> +		goto failed;
> +	}
>  	ctdb->name = talloc_asprintf(ctdb, "%s:%u",
>  				     ctdb_addr_to_str(ctdb->address),
>  				     ctdb_addr_to_port(ctdb->address));
> -- 
> 1.7.1
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20150331/66401faf/attachment.pgp>


More information about the samba-technical mailing list