Skip to content

Commit 9f116f7

Browse files
committed
tracing: Check field value in hist_field_name()
The function hist_field_name() cannot handle being passed a NULL field parameter. It should never be NULL, but due to a previous bug, NULL was passed to the function and the kernel crashed due to a NULL dereference. Mark Rutland reported this to me on IRC. The bug was fixed, but to prevent future bugs from crashing the kernel, check the field and add a WARN_ON() if it is NULL. Link: https://lkml.kernel.org/r/[email protected] Cc: [email protected] Cc: Masami Hiramatsu <[email protected]> Cc: Andrew Morton <[email protected]> Reported-by: Mark Rutland <[email protected]> Fixes: c6afad4 ("tracing: Add hist trigger 'sym' and 'sym-offset' modifiers") Tested-by: Mark Rutland <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent e021343 commit 9f116f7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kernel/trace/trace_events_hist.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,9 @@ static const char *hist_field_name(struct hist_field *field,
13311331
{
13321332
const char *field_name = "";
13331333

1334+
if (WARN_ON_ONCE(!field))
1335+
return field_name;
1336+
13341337
if (level > 1)
13351338
return field_name;
13361339

0 commit comments

Comments
 (0)