From 8f29301e882f36fd6e33b94b4920855ba3261512 Mon Sep 17 00:00:00 2001 From: Andrew Vagin <avagin@virtuozzo.com> Date: Thu, 26 Nov 2015 09:12:33 +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 --- seccomp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/seccomp.c b/seccomp.c index 50f6a70b48c..1dd0de23b00 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);