diff options
author | Henrique Mecking <henriquemecking@gmail.com> | 2013-08-18 11:43:02 -0500 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2013-08-20 10:24:23 +1000 |
commit | b9ed25e1c5b3014982507adcfaa3597b6e416305 (patch) | |
tree | 13749e13677841867915c130915065fd1d04bb8c | |
parent | 8ff8a620951d9f8525e686bc47fdb38b58aaa9ca (diff) | |
download | ipvsadm-b9ed25e1c5b3014982507adcfaa3597b6e416305.tar.gz |
libipvs: Fix memory leak
If malloc fails, free allocated memory before returning NULL.
Signed-off-by: Ryan O'Hara <rohara@redhat.com>
Acked-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r-- | libipvs/libipvs.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libipvs/libipvs.c b/libipvs/libipvs.c index 89f26b9..ef242db 100644 --- a/libipvs/libipvs.c +++ b/libipvs/libipvs.c @@ -668,8 +668,10 @@ struct ip_vs_get_services *ipvs_get_services(void) return NULL; len = sizeof(*getk) + sizeof(struct ip_vs_service_entry_kern) * ipvs_info.num_services; - if (!(getk = malloc(len))) + if (!(getk = malloc(len))) { + free(get); return NULL; + } ipvs_func = ipvs_get_services; getk->num_services = ipvs_info.num_services; @@ -853,8 +855,10 @@ ipvs_nl_dest_failure: } len = sizeof(*dk) + sizeof(struct ip_vs_dest_entry_kern) * svc->num_dests; - if (!(dk = malloc(len))) + if (!(dk = malloc(len))) { + free(d); return NULL; + } dk->fwmark = svc->fwmark; dk->protocol = svc->protocol; |