From: Henrique Mecking <henriquemecking@xxxxxxxxx> If malloc fails, free allocated memory before returning NULL. Signed-off-by: Ryan O'Hara <rohara@xxxxxxxxxx> --- libipvs/libipvs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libipvs/libipvs.c b/libipvs/libipvs.c index 2b066d2..1c9e066 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; -- 1.8.1.4 -- To unsubscribe from this list: send the line "unsubscribe lvs-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html