mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [2.6.31 PATCH] tracing/filters: always free pred on filter_add_subsystem_pred() failure
@ 2009-08-08 15:49 Tom Zanussi
  2009-08-08 16:02 ` Ingo Molnar
  2009-08-08 16:03 ` [tip:tracing/core] tracing/filters: Always " tip-bot for Tom Zanussi
  0 siblings, 2 replies; 4+ messages in thread
From: Tom Zanussi @ 2009-08-08 15:49 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Steven Rostedt, Frederic Weisbecker, Li Zefan, LKML

If filter_add_subsystem_pred() fails due to ENOSPC or ENOMEM, the pred
doesn't get freed, while as a side effect it does for other errors.
Make it so the caller always frees the pred for any error.

Signed-off-by: Tom Zanussi <tzanussi@gmail.com>
---
 kernel/trace/trace_events_filter.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 1557148..f32dc9d 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -624,9 +624,6 @@ static int filter_add_subsystem_pred(struct filter_parse_state *ps,
 		return -ENOSPC;
 	}
 
-	filter->preds[filter->n_preds] = pred;
-	filter->n_preds++;
-
 	list_for_each_entry(call, &ftrace_events, list) {
 
 		if (!call->define_fields)
@@ -643,6 +640,9 @@ static int filter_add_subsystem_pred(struct filter_parse_state *ps,
 		}
 		replace_filter_string(call->filter, filter_string);
 	}
+
+	filter->preds[filter->n_preds] = pred;
+	filter->n_preds++;
 out:
 	return err;
 }
@@ -1034,9 +1034,12 @@ static int replace_preds(struct event_subsystem *system,
 			if (call) {
 				err = filter_add_pred(ps, call, pred);
 				filter_free_pred(pred);
-			} else
+			} else {
 				err = filter_add_subsystem_pred(ps, system,
 							pred, filter_string);
+				if (err)
+					filter_free_pred(pred);
+			}
 			if (err)
 				return err;
 
@@ -1055,9 +1058,12 @@ static int replace_preds(struct event_subsystem *system,
 		if (call) {
 			err = filter_add_pred(ps, call, pred);
 			filter_free_pred(pred);
-		} else
+		} else {
 			err = filter_add_subsystem_pred(ps, system, pred,
 							filter_string);
+			if (err)
+				filter_free_pred(pred);
+		}
 		if (err)
 			return err;
 
-- 
1.5.6.3




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [2.6.31 PATCH] tracing/filters: always free pred on filter_add_subsystem_pred() failure
  2009-08-08 15:49 [2.6.31 PATCH] tracing/filters: always free pred on filter_add_subsystem_pred() failure Tom Zanussi
@ 2009-08-08 16:02 ` Ingo Molnar
  2009-08-08 16:04   ` Tom Zanussi
  2009-08-08 16:03 ` [tip:tracing/core] tracing/filters: Always " tip-bot for Tom Zanussi
  1 sibling, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2009-08-08 16:02 UTC (permalink / raw)
  To: Tom Zanussi; +Cc: Steven Rostedt, Frederic Weisbecker, Li Zefan, LKML


* Tom Zanussi <tzanussi@gmail.com> wrote:

> If filter_add_subsystem_pred() fails due to ENOSPC or ENOMEM, the 
> pred doesn't get freed, while as a side effect it does for other 
> errors. Make it so the caller always frees the pred for any error.

thanks, i've queued this up for .31.

Just to make sure: tracing/core has the filter code changed 
substantially, and this issue seems to be moot there - correct?

So the total impact from both patches on -tip is the patch below - 
right?

	Ingo

diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 27c2dbe..490337a 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -1050,6 +1050,8 @@ static int replace_preds(struct event_subsystem *system,
 
 		pred = create_pred(elt->op, operand1, operand2);
 add_pred:
+		if (!pred)
+			return -ENOMEM;
 		if (call)
 			err = filter_add_pred(ps, call, pred, false);
 		else

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:tracing/core] tracing/filters: Always free pred on filter_add_subsystem_pred() failure
  2009-08-08 15:49 [2.6.31 PATCH] tracing/filters: always free pred on filter_add_subsystem_pred() failure Tom Zanussi
  2009-08-08 16:02 ` Ingo Molnar
@ 2009-08-08 16:03 ` tip-bot for Tom Zanussi
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Tom Zanussi @ 2009-08-08 16:03 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, tzanussi, lizf, fweisbec, rostedt, tglx, mingo

Commit-ID:  26528e773ecc74fb1b61b7275f86f761cbb340ec
Gitweb:     http://git.kernel.org/tip/26528e773ecc74fb1b61b7275f86f761cbb340ec
Author:     Tom Zanussi <tzanussi@gmail.com>
AuthorDate: Sat, 8 Aug 2009 10:49:53 -0500
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Sat, 8 Aug 2009 17:56:13 +0200

tracing/filters: Always free pred on filter_add_subsystem_pred() failure

If filter_add_subsystem_pred() fails due to ENOSPC or ENOMEM,
the pred doesn't get freed, while as a side effect it does for
other errors. Make it so the caller always frees the pred for
any error.

Signed-off-by: Tom Zanussi <tzanussi@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <1249746593.6453.32.camel@tropicana>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 kernel/trace/trace_events_filter.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 1557148..f32dc9d 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -624,9 +624,6 @@ static int filter_add_subsystem_pred(struct filter_parse_state *ps,
 		return -ENOSPC;
 	}
 
-	filter->preds[filter->n_preds] = pred;
-	filter->n_preds++;
-
 	list_for_each_entry(call, &ftrace_events, list) {
 
 		if (!call->define_fields)
@@ -643,6 +640,9 @@ static int filter_add_subsystem_pred(struct filter_parse_state *ps,
 		}
 		replace_filter_string(call->filter, filter_string);
 	}
+
+	filter->preds[filter->n_preds] = pred;
+	filter->n_preds++;
 out:
 	return err;
 }
@@ -1034,9 +1034,12 @@ static int replace_preds(struct event_subsystem *system,
 			if (call) {
 				err = filter_add_pred(ps, call, pred);
 				filter_free_pred(pred);
-			} else
+			} else {
 				err = filter_add_subsystem_pred(ps, system,
 							pred, filter_string);
+				if (err)
+					filter_free_pred(pred);
+			}
 			if (err)
 				return err;
 
@@ -1055,9 +1058,12 @@ static int replace_preds(struct event_subsystem *system,
 		if (call) {
 			err = filter_add_pred(ps, call, pred);
 			filter_free_pred(pred);
-		} else
+		} else {
 			err = filter_add_subsystem_pred(ps, system, pred,
 							filter_string);
+			if (err)
+				filter_free_pred(pred);
+		}
 		if (err)
 			return err;
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [2.6.31 PATCH] tracing/filters: always free pred on filter_add_subsystem_pred() failure
  2009-08-08 16:02 ` Ingo Molnar
@ 2009-08-08 16:04   ` Tom Zanussi
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Zanussi @ 2009-08-08 16:04 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Steven Rostedt, Frederic Weisbecker, Li Zefan, LKML

On Sat, 2009-08-08 at 18:02 +0200, Ingo Molnar wrote:
> * Tom Zanussi <tzanussi@gmail.com> wrote:
> 
> > If filter_add_subsystem_pred() fails due to ENOSPC or ENOMEM, the 
> > pred doesn't get freed, while as a side effect it does for other 
> > errors. Make it so the caller always frees the pred for any error.
> 
> thanks, i've queued this up for .31.
> 
> Just to make sure: tracing/core has the filter code changed 
> substantially, and this issue seems to be moot there - correct?
> 

Right, the subsystem preds are gone in tip, so nothing to fix there.

> So the total impact from both patches on -tip is the patch below - 
> right?
> 

Right.

Tom

> 	Ingo
> 
> diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
> index 27c2dbe..490337a 100644
> --- a/kernel/trace/trace_events_filter.c
> +++ b/kernel/trace/trace_events_filter.c
> @@ -1050,6 +1050,8 @@ static int replace_preds(struct event_subsystem *system,
>  
>  		pred = create_pred(elt->op, operand1, operand2);
>  add_pred:
> +		if (!pred)
> +			return -ENOMEM;
>  		if (call)
>  			err = filter_add_pred(ps, call, pred, false);
>  		else


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-08-08 16:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-08 15:49 [2.6.31 PATCH] tracing/filters: always free pred on filter_add_subsystem_pred() failure Tom Zanussi
2009-08-08 16:02 ` Ingo Molnar
2009-08-08 16:04   ` Tom Zanussi
2009-08-08 16:03 ` [tip:tracing/core] tracing/filters: Always " tip-bot for Tom Zanussi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®