[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-ha-dev
Subject:    Re: [Linux-ha-dev] [patch 01/10] send_ua() is leaking l
From:       Simon Horman <horms () verge ! net ! au>
Date:       2007-04-16 7:49:14
Message-ID: 20070416074912.GC28064 () verge ! net ! au
[Download RAW message or body]

On Fri, Apr 13, 2007 at 10:48:00AM +0200, Dejan Muhamedagic wrote:
> On Fri, Apr 13, 2007 at 04:02:31PM +0900, Simon Horman wrote:
> > Currently send_ua() does not call libnet_destroy() on the handle
> > that it creates using libnet_init() resulting in some memory leakage.
> > 
> > Index: heartbeat-ipv6addr/resources/OCF/IPv6addr.c
> > ===================================================================
> > --- heartbeat-ipv6addr.orig/resources/OCF/IPv6addr.c	2007-04-13 15:35:21.000000000 +0900
> > +++ heartbeat-ipv6addr/resources/OCF/IPv6addr.c	2007-04-13 15:40:39.000000000 +0900
> > @@ -378,6 +378,7 @@
> >  int
> >  send_ua(struct in6_addr* src_ip, char* if_name)
> >  {
> > +	int status = -1;
> >  	libnet_t *l;
> >  	char errbuf[LIBNET_ERRBUF_SIZE];
> >  
> > @@ -388,13 +389,13 @@
> >  
> >  	if ((l=libnet_init(LIBNET_RAW6, if_name, errbuf)) == NULL) {
> >  		cl_log(LOG_ERR, "libnet_init failure on %s", if_name);
> > -		return -1;
> > +		goto err;
> >  	}
> >  
> >  	mac_address = libnet_get_hwaddr(l);
> >  	if (!mac_address) {
> >  		cl_log(LOG_ERR, "libnet_get_hwaddr: %s", errbuf);
> > -		return -1;
> > +		goto err;
> >  	}
> >  
> >  	dst_ip = libnet_name2addr6(l, BCAST_ADDR, LIBNET_DONT_RESOLVE);
> > @@ -415,10 +416,13 @@
> >          if (libnet_write(l) == -1)
> >          {
> >  		cl_log(LOG_ERR, "libnet_write: %s", libnet_geterror(l));
> > -		return -1;
> > +		goto err;
> >  	}
> >  
> > -	return 0;
> > +	status = -1;
> 
> shouldn't this be:	status = 0;

Yes, indeed it should.

-- 
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/

_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic