Skip to contentSkip to conversation

tracing: Fix a potential NULL dereference

PATCH In review Dan Carpenter 3 participants 3 messages Mar 23, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing: Fix a potential NULL dereference

We forgot to set the error code on this path so we return ERR_PTR(0) which is NULL. It results in a NULL dereference in the caller.

Fixes 100719dcef44 ("tracing: Add simple expression support to hist triggers")
kernel/trace/trace_events_hist.c +1 -0
index 4f027642ceef..a02bc09d765a 100644
@@ -2776,6 +2776,7 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data,
 		expr->fn = hist_field_plus;
 		break;
 	default:
+		ret = -EINVAL;
 		goto free;
 	}
 
Acked-by on v1 1/1
#1 lore raw

Hi Dan,

Quoted 11 lines · Dan Carpenter

We forgot to set the error code on this path so we return ERR_PTR(0) which is NULL. It results in a NULL dereference in the caller.

Fixes 100719dcef44 ("tracing: Add simple expression support to hist triggers")
kernel/trace/trace_events_hist.c +0 -0
index 4f027642ceef..a02bc09d765a 100644

kernel/trace/trace_events_hist.c static struct hist_field *parse_expr(struct hist_trigger_data *hist_data, · line 2782

Quoted 7 lines
kernel/trace/trace_events_hist.c +1 -0
@@ -2776,6 +2776,7 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data,
 		expr->fn = hist_field_plus;
 		break;
 	default:
+		ret = -EINVAL;
 		goto free;
 	}
 

Thanks for catching this!

Tom