[CRIU] [PATCH 10/13] ipc_ns: free allocated objects at the end

Andrey Vagin avagin at openvz.org
Wed Apr 3 13:31:09 EDT 2013


ipc_ns.c:464:3: warning: Memory is never released; potential leak of
memory pointed to by 'values'
                return;
                ^
1 warning generated.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 ipc_ns.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ipc_ns.c b/ipc_ns.c
index 8717126..ded8c87 100644
--- a/ipc_ns.c
+++ b/ipc_ns.c
@@ -460,8 +460,10 @@ static void ipc_sem_handler(int fd, void *obj, int show_pages_content)
 	values = xmalloc(size);
 	if (values == NULL)
 		return;
-	if (read_img_buf(fd, values, round_up(size, sizeof(u64))) <= 0)
+	if (read_img_buf(fd, values, round_up(size, sizeof(u64))) <= 0) {
+		xfree(values);
 		return;
+	}
 	pr_msg_ipc_sem_array(e->nsems, values);
 }
 
-- 
1.7.11.7



More information about the CRIU mailing list