From d55e13d4f384ac34498df0aed7bc2219024d8375 Mon Sep 17 00:00:00 2001 From: Andrew Vagin Date: Thu, 26 Nov 2015 09:13:00 +0300 Subject: [PATCH] seccomp: don't leak info on an error path CID 154852 (#1 of 3): Resource leak (RESOURCE_LEAK) 32. leaked_storage: Variable info going out of scope leaks the storage it points to. Reported-by: coverity Signed-off-by: Andrew Vagin Signed-off-by: Pavel Emelyanov --- seccomp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/seccomp.c b/seccomp.c index 50f6a70b48..1dd0de23b0 100644 --- a/seccomp.c +++ b/seccomp.c @@ -97,8 +97,10 @@ static int collect_filter_for_pstree(struct pstree_item *item) info->filter.filter.len = len * sizeof(struct sock_filter); info->filter.filter.data = xmalloc(info->filter.filter.len); - if (!info->filter.filter.data) + if (!info->filter.filter.data) { + xfree(info); goto out; + } memcpy(info->filter.filter.data, buf, info->filter.filter.len);