aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/trace/trace_events_filter.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index ced69da0ff55..7f2e97ce71a7 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -1369,19 +1369,26 @@ static int check_preds(struct filter_parse_state *ps)
1369{ 1369{
1370 int n_normal_preds = 0, n_logical_preds = 0; 1370 int n_normal_preds = 0, n_logical_preds = 0;
1371 struct postfix_elt *elt; 1371 struct postfix_elt *elt;
1372 int cnt = 0;
1372 1373
1373 list_for_each_entry(elt, &ps->postfix, list) { 1374 list_for_each_entry(elt, &ps->postfix, list) {
1374 if (elt->op == OP_NONE) 1375 if (elt->op == OP_NONE) {
1376 cnt++;
1375 continue; 1377 continue;
1378 }
1376 1379
1377 if (elt->op == OP_AND || elt->op == OP_OR) { 1380 if (elt->op == OP_AND || elt->op == OP_OR) {
1378 n_logical_preds++; 1381 n_logical_preds++;
1382 cnt--;
1379 continue; 1383 continue;
1380 } 1384 }
1385 if (elt->op != OP_NOT)
1386 cnt--;
1381 n_normal_preds++; 1387 n_normal_preds++;
1388 WARN_ON_ONCE(cnt < 0);
1382 } 1389 }
1383 1390
1384 if (!n_normal_preds || n_logical_preds >= n_normal_preds) { 1391 if (cnt != 1 || !n_normal_preds || n_logical_preds >= n_normal_preds) {
1385 parse_error(ps, FILT_ERR_INVALID_FILTER, 0); 1392 parse_error(ps, FILT_ERR_INVALID_FILTER, 0);
1386 return -EINVAL; 1393 return -EINVAL;
1387 } 1394 }