diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace.h | 2 | ||||
-rw-r--r-- | kernel/trace/trace_events_filter.c | 31 |
2 files changed, 10 insertions, 23 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 441fc1bc85d6..254d04a84ec3 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -663,7 +663,7 @@ struct ftrace_event_field { | |||
663 | struct event_filter { | 663 | struct event_filter { |
664 | int n_preds; /* Number assigned */ | 664 | int n_preds; /* Number assigned */ |
665 | int a_preds; /* allocated */ | 665 | int a_preds; /* allocated */ |
666 | struct filter_pred **preds; | 666 | struct filter_pred *preds; |
667 | char *filter_string; | 667 | char *filter_string; |
668 | }; | 668 | }; |
669 | 669 | ||
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 8f00a11ce778..b6c910642a1e 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c | |||
@@ -362,7 +362,7 @@ int filter_match_preds(struct event_filter *filter, void *rec) | |||
362 | { | 362 | { |
363 | int match = -1, top = 0, val1 = 0, val2 = 0; | 363 | int match = -1, top = 0, val1 = 0, val2 = 0; |
364 | int stack[MAX_FILTER_PRED]; | 364 | int stack[MAX_FILTER_PRED]; |
365 | struct filter_pred **preds; | 365 | struct filter_pred *preds; |
366 | struct filter_pred *pred; | 366 | struct filter_pred *pred; |
367 | int n_preds = ACCESS_ONCE(filter->n_preds); | 367 | int n_preds = ACCESS_ONCE(filter->n_preds); |
368 | int i; | 368 | int i; |
@@ -377,7 +377,7 @@ int filter_match_preds(struct event_filter *filter, void *rec) | |||
377 | preds = rcu_dereference_sched(filter->preds); | 377 | preds = rcu_dereference_sched(filter->preds); |
378 | 378 | ||
379 | for (i = 0; i < n_preds; i++) { | 379 | for (i = 0; i < n_preds; i++) { |
380 | pred = preds[i]; | 380 | pred = &preds[i]; |
381 | if (!pred->pop_n) { | 381 | if (!pred->pop_n) { |
382 | match = pred->fn(pred, rec); | 382 | match = pred->fn(pred, rec); |
383 | stack[top++] = match; | 383 | stack[top++] = match; |
@@ -559,10 +559,8 @@ static void __free_preds(struct event_filter *filter) | |||
559 | int i; | 559 | int i; |
560 | 560 | ||
561 | if (filter->preds) { | 561 | if (filter->preds) { |
562 | for (i = 0; i < filter->a_preds; i++) { | 562 | for (i = 0; i < filter->a_preds; i++) |
563 | if (filter->preds[i]) | 563 | kfree(filter->preds[i].field_name); |
564 | filter_free_pred(filter->preds[i]); | ||
565 | } | ||
566 | kfree(filter->preds); | 564 | kfree(filter->preds); |
567 | filter->preds = NULL; | 565 | filter->preds = NULL; |
568 | } | 566 | } |
@@ -572,7 +570,6 @@ static void __free_preds(struct event_filter *filter) | |||
572 | 570 | ||
573 | static void reset_preds(struct event_filter *filter) | 571 | static void reset_preds(struct event_filter *filter) |
574 | { | 572 | { |
575 | struct filter_pred *pred; | ||
576 | int n_preds = filter->n_preds; | 573 | int n_preds = filter->n_preds; |
577 | int i; | 574 | int i; |
578 | 575 | ||
@@ -580,10 +577,8 @@ static void reset_preds(struct event_filter *filter) | |||
580 | if (!filter->preds) | 577 | if (!filter->preds) |
581 | return; | 578 | return; |
582 | 579 | ||
583 | for (i = 0; i < n_preds; i++) { | 580 | for (i = 0; i < n_preds; i++) |
584 | pred = filter->preds[i]; | 581 | filter->preds[i].fn = filter_pred_none; |
585 | pred->fn = filter_pred_none; | ||
586 | } | ||
587 | } | 582 | } |
588 | 583 | ||
589 | static void filter_disable_preds(struct ftrace_event_call *call) | 584 | static void filter_disable_preds(struct ftrace_event_call *call) |
@@ -658,19 +653,11 @@ static int __alloc_preds(struct event_filter *filter, int n_preds) | |||
658 | return -EINVAL; | 653 | return -EINVAL; |
659 | 654 | ||
660 | for (i = 0; i < n_preds; i++) { | 655 | for (i = 0; i < n_preds; i++) { |
661 | pred = filter->preds[i]; | 656 | pred = &filter->preds[i]; |
662 | if (!pred) | ||
663 | pred = kzalloc(sizeof(*pred), GFP_KERNEL); | ||
664 | if (!pred) | ||
665 | goto oom; | ||
666 | pred->fn = filter_pred_none; | 657 | pred->fn = filter_pred_none; |
667 | filter->preds[i] = pred; | ||
668 | } | 658 | } |
669 | 659 | ||
670 | return 0; | 660 | return 0; |
671 | oom: | ||
672 | __free_preds(filter); | ||
673 | return -ENOMEM; | ||
674 | } | 661 | } |
675 | 662 | ||
676 | static int init_filter(struct ftrace_event_call *call) | 663 | static int init_filter(struct ftrace_event_call *call) |
@@ -730,8 +717,8 @@ static int filter_add_pred_fn(struct filter_parse_state *ps, | |||
730 | } | 717 | } |
731 | 718 | ||
732 | idx = filter->n_preds; | 719 | idx = filter->n_preds; |
733 | filter_clear_pred(filter->preds[idx]); | 720 | filter_clear_pred(&filter->preds[idx]); |
734 | err = filter_set_pred(filter->preds[idx], pred, fn); | 721 | err = filter_set_pred(&filter->preds[idx], pred, fn); |
735 | if (err) | 722 | if (err) |
736 | return err; | 723 | return err; |
737 | 724 | ||