Skip to contentSkip to conversation

tracing/filters: don't use pred on alloc failure

PATCH In review Tom Zanussi 1 participant 2 messages Aug 8, 2009 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing/filters: don't use pred on alloc failure

Dan Carpenter sent me a fix to prevent pred from being used if it couldn't be allocated. I noticed the same problem also existed for the create_pred() case and added a fix for that.

The original report:

create_logical_pred() could sometimes return NULL.

It's a static checker complaining rather than problems at runtime...

---
 kernel/trace/trace_events_filter.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/trace/trace_events_filter.c +4 -0
index 936c621..1557148 100644
@@ -1029,6 +1029,8 @@ static int replace_preds(struct event_subsystem *system,
 
 		if (elt->op == OP_AND || elt->op == OP_OR) {
 			pred = create_logical_pred(elt->op);
+			if (!pred)
+				return -ENOMEM;
 			if (call) {
 				err = filter_add_pred(ps, call, pred);
 				filter_free_pred(pred);
@@ -1048,6 +1050,8 @@ static int replace_preds(struct event_subsystem *system,
 		}
 
 		pred = create_pred(elt->op, operand1, operand2);
+		if (!pred)
+			return -ENOMEM;
 		if (call) {
 			err = filter_add_pred(ps, call, pred);
 			filter_free_pred(pred);
Signature · 1 line
1.5.6.3
#1 lore raw

[tip:tracing/core] tracing/filters: Don't use pred on alloc failure

Commit-ID:  96b2de313b1e0e02aea80ee47df6a2b5cbdf8e13
Gitweb:     http://git.kernel.org/tip/96b2de313b1e0e02aea80ee47df6a2b5cbdf8e13
Author:     Tom Zanussi <[email protected]>
AuthorDate: Sat, 8 Aug 2009 10:49:09 -0500
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 8 Aug 2009 17:55:34 +0200

tracing/filters: Don't use pred on alloc failure

Dan Carpenter sent me a fix to prevent pred from being used if it couldn't be allocated. I noticed the same problem also existed for the create_pred() case and added a fix for that.

Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Li Zefan <[email protected]>

LKML-Reference: <1249746549.6453.29.camel@tropicana>

---
 kernel/trace/trace_events_filter.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/trace/trace_events_filter.c +4 -0
index 936c621..1557148 100644
@@ -1029,6 +1029,8 @@ static int replace_preds(struct event_subsystem *system,
 
 		if (elt->op == OP_AND || elt->op == OP_OR) {
 			pred = create_logical_pred(elt->op);
+			if (!pred)
+				return -ENOMEM;
 			if (call) {
 				err = filter_add_pred(ps, call, pred);
 				filter_free_pred(pred);
@@ -1048,6 +1050,8 @@ static int replace_preds(struct event_subsystem *system,
 		}
 
 		pred = create_pred(elt->op, operand1, operand2);
+		if (!pred)
+			return -ENOMEM;
 		if (call) {
 			err = filter_add_pred(ps, call, pred);
 			filter_free_pred(pred);