[CRIU] [PATCH 08/13] sockets: free all allocated objected in case of any error

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


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

diff --git a/sockets.c b/sockets.c
index eb17409..f2af068 100644
--- a/sockets.c
+++ b/sockets.c
@@ -193,12 +193,15 @@ static int dump_socket_filter(int sk, SkOptsEntry *soe)
 	ret = getsockopt(sk, SOL_SOCKET, SO_GET_FILTER, flt, &len);
 	if (ret) {
 		pr_perror("Can't get socket filter\n");
+		xfree(flt);
 		return ret;
 	}
 
 	soe->so_filter = xmalloc(len * sizeof(*soe->so_filter));
-	if (!soe->so_filter)
+	if (!soe->so_filter) {
+		xfree(flt);
 		return -1;
+	}
 
 	encode_filter(flt, soe->so_filter, len);
 	soe->n_so_filter = len;
-- 
1.7.11.7



More information about the CRIU mailing list