[23/28] seccomp: dump_seccomp_filters -- Be ready for chains absence

Submitted by Cyrill Gorcunov on March 20, 2018, 9:43 p.m.

Details

Message ID 20180320214313.25326-24-gorcunov@gmail.com
State Rejected
Series "seccomp, v2: Add support for per-thread tracking"
Headers show

Commit Message

Cyrill Gorcunov March 20, 2018, 9:43 p.m.
From: Cyrill Gorcunov <gorcunov@openvz.org>

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
 criu/seccomp.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/seccomp.c b/criu/seccomp.c
index 90484cde5cb5..3416ba0c6060 100644
--- a/criu/seccomp.c
+++ b/criu/seccomp.c
@@ -311,9 +311,11 @@  static int dump_seccomp_filters(void)
 	}
 
 	se.n_seccomp_filters = nr_chains;
-	se.seccomp_filters = xmalloc(sizeof(*se.seccomp_filters) * nr_chains);
-	if (!se.seccomp_filters)
-		return -1;
+	if (nr_chains) {
+		se.seccomp_filters = xmalloc(sizeof(*se.seccomp_filters) * nr_chains);
+		if (!se.seccomp_filters)
+			return -1;
+	}
 
 	for (node = rb_first(&seccomp_tid_rb_root); node; node = rb_next(node)) {
 		entry = rb_entry(node, struct seccomp_entry, node);