Skip to content

Commit 8b152e9

Browse files
Natalia Petrovarostedt
authored andcommitted
trace_events_hist: add check for return value of 'create_hist_field'
Function 'create_hist_field' is called recursively at trace_events_hist.c:1954 and can return NULL-value that's why we have to check it to avoid null pointer dereference. Found by Linux Verification Center (linuxtesting.org) with SVACE. Link: https://lkml.kernel.org/r/[email protected] Cc: [email protected] Fixes: 30350d6 ("tracing: Add variable support to hist triggers") Signed-off-by: Natalia Petrova <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 685b64e commit 8b152e9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

kernel/trace/trace_events_hist.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,6 +1988,8 @@ static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data,
19881988
hist_field->fn_num = flags & HIST_FIELD_FL_LOG2 ? HIST_FIELD_FN_LOG2 :
19891989
HIST_FIELD_FN_BUCKET;
19901990
hist_field->operands[0] = create_hist_field(hist_data, field, fl, NULL);
1991+
if (!hist_field->operands[0])
1992+
goto free;
19911993
hist_field->size = hist_field->operands[0]->size;
19921994
hist_field->type = kstrdup_const(hist_field->operands[0]->type, GFP_KERNEL);
19931995
if (!hist_field->type)

0 commit comments

Comments
 (0)