From 853937d1bdcc4b5e69a778a0193d7d647f4440ae Mon Sep 17 00:00:00 2001 From: Ryan McCabe <rmccabe@redhat.com> Date: Thu, 25 May 2017 13:57:40 -0400 Subject: [PATCH] fence-virtd: Cleanup small memory leak Clean up a small memory leak in the TCP plugin on an error path. Signed-off-by: Ryan McCabe <rmccabe@redhat.com> --- server/tcp.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/server/tcp.c b/server/tcp.c index 0002e8f..5f98f2c 100644 --- a/server/tcp.c +++ b/server/tcp.c @@ -455,11 +455,17 @@ tcp_init(listener_context_t *c, const fence_callbacks_t *cb, info->map = map; ret = tcp_config(config, &info->args); - if (ret < 0) { + if (ret < 0) perror("tcp_config"); - return -1; - } else if (ret > 0) { + else if (ret > 0) printf("%d errors found during configuration\n",ret); + + if (ret != 0) { + if (info->args.key_file) + free(info->args.key_file); + if (info->args.addr) + free(info->args.addr); + free(info); return -1; } @@ -483,6 +489,10 @@ tcp_init(listener_context_t *c, const fence_callbacks_t *cb, if (listen_sock < 0) { printf("Could not set up listen socket\n"); + if (info->args.key_file) + free(info->args.key_file); + if (info->args.addr) + free(info->args.addr); free(info); return -1; }