tracing: Uninitialized variable in create_tracing_map_fields()
Subsystems (2)
PATCH 1/1 tracing: Uninitialized variable in create_tracing_map_fields()
Smatch complains that idx can be used uninitialized when we check if (idx < 0). It has to be the first iteration through the loop and the HIST_FIELD_FL_STACKTRACE bit has to be clear and the HIST_FIELD_FL_VAR bit has to be set to reach the bug.
kernel/trace/trace_events_hist.c +1 -1
@@ -4411,7 +4411,7 @@ static int create_tracing_map_fields(struct hist_trigger_data *hist_data)struct tracing_map *map = hist_data->map;struct ftrace_event_field *field;struct hist_field *hist_field; -int i, idx; +int i, idx =0 ;for_each_hist_field (i, hist_data) { hist_field = hist_data->fields[i];
Hi Dan,
Quoted 13 lines · Dan Carpenter
Smatch complains that idx can be used uninitialized when we check if (idx < 0). It has to be the first iteration through the loop and the
HIST_FIELD_FL_STACKTRACEbit has to be clear and theHIST_FIELD_FL_VARbit has to be set to reach the bug.Fixes 30350d65ac56 ("tracing: Add variable support to hist triggers")Signed-off-by Dan Carpenter <[email protected]>kernel/trace/trace_events_hist.c +0
-0
kernel/trace/trace_events_hist.c static int create_tracing_map_fields(struct hist_trigger_data *hist_data) · line 4417
Quoted 8 lines
kernel/trace/trace_events_hist.c +1
-1@@ -4411,7 +4411,7 @@ static int create_tracing_map_fields(struct hist_trigger_data *hist_data)struct tracing_map *map = hist_data->map;struct ftrace_event_field *field;struct hist_field *hist_field; -int i, idx; +int i, idx =0 ;for_each_hist_field (i, hist_data) { hist_field = hist_data->fields[i];
Yes, this should definitely be initialized to 0, thanks for the patch!
Steven Rostedt
maintainerQuoted 3 lines · On Wed, 28 Mar 2018 09:04:40 -0500 Tom Zanussi <[email protected]>…
Yes, this should definitely be initialized to 0, thanks for the patch!
Acked-by Tom Zanussi <[email protected]>
Thanks, I applied it and will push to git after it has succeeded in testing.
-- Steve