From: Phil Sutter <phil@nwl.cc> Date: 2017-08-17 17:13:29
This series collects patches from v1 which deal with potential memory leaks.
No changes to the actual patches, just splitting into smaller series.
Phil Sutter (5):
ipvrf: Fix error path of vrf_switch()
ifstat: Fix memleak in error case
ifstat: Fix memleak in dump_kern_db() for json output
ss: Fix potential memleak in unix_stats_print()
tipc/bearer: Fix resource leak in error path
ip/ipvrf.c | 9 +++++----
misc/ifstat.c | 12 +++++++++---
misc/ss.c | 4 +++-
tipc/bearer.c | 3 +++
4 files changed, 20 insertions(+), 8 deletions(-)
--
2.13.1
@@ -163,6 +163,7 @@ static int nl_add_udp_enable_opts(struct nlmsghdr *nlh, struct opt *opts,if(!remip){if(generate_multicast(loc->ai_family,buf,sizeof(buf))){fprintf(stderr,"Failed to generate multicast address\n");+freeaddrinfo(loc);return-EINVAL;}remip=buf;
@@ -177,6 +178,8 @@ static int nl_add_udp_enable_opts(struct nlmsghdr *nlh, struct opt *opts,if(rem->ai_family!=loc->ai_family){fprintf(stderr,"UDP local and remote AF mismatch\n");+freeaddrinfo(rem);+freeaddrinfo(loc);return-EINVAL;}
From: Phil Sutter <phil@nwl.cc> Date: 2017-08-17 17:12:26
Apart from trying to close(-1), this also leaked memory.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
ip/ipvrf.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
@@ -372,12 +372,12 @@ static int vrf_switch(const char *name)/* -1 on length to add '/' to the end */if(ipvrf_get_netns(netns,sizeof(netns)-1)<0)-return-1;+gotoout;if(vrf_path(vpath,sizeof(vpath))<0){fprintf(stderr,"Failed to get base cgroup path: %s\n",strerror(errno));-return-1;+gotoout;}/* if path already ends in netns then don't add it again */
@@ -428,13 +428,14 @@ static int vrf_switch(const char *name)snprintf(pid,sizeof(pid),"%d",getpid());if(write(fd,pid,strlen(pid))<0){fprintf(stderr,"Failed to join cgroup\n");-gotoout;+gotoout2;}rc=0;+out2:+close(fd);out:free(mnt);-close(fd);returnrc;}
From: Phil Sutter <phil@nwl.cc> Date: 2017-08-17 17:13:48
Looks like this was forgotten when converting to common json output
formatter.
Fixes: fcc16c2287bf8 ("provide common json output formatter")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ifstat.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)