[18/28] seccomp: Don't use BUG_ON in dump_seccomp_filters

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

Details

Message ID 20180320214313.25326-19-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@virtuozzo.com>

Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
---
 criu/seccomp.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/seccomp.c b/criu/seccomp.c
index 76b0acdf9372..a4304e645de7 100644
--- a/criu/seccomp.c
+++ b/criu/seccomp.c
@@ -252,7 +252,12 @@  static int dump_seccomp_filters(void)
 			continue;
 
 		for (chain = entry->chain; chain; chain = chain->prev) {
-			BUG_ON(img_filter_pos >= nr_chains);
+			if (img_filter_pos >= nr_chains) {
+				pr_err("Unexpected position %zu > %zu\n",
+				       img_filter_pos, nr_chains);
+				xfree(se.seccomp_filters);
+				return -1;
+			}
 
 			se.seccomp_filters[img_filter_pos] = &chain->filter;
 			if (chain != entry->chain) {