Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
rtla/osnoise: Prevent NULL dereference in error handling
Browse files Browse the repository at this point in the history
commit 90574d2 upstream.

If the "tool->data" allocation fails then there is no need to call
osnoise_free_top() and, in fact, doing so will lead to a NULL dereference.

Cc: [email protected]
Cc: John Kacur <[email protected]>
Cc: "Luis Claudio R. Goncalves" <[email protected]>
Cc: Clark Williams <[email protected]>
Fixes: 1eceb2f ("rtla/osnoise: Add osnoise top mode")
Link: https://lore.kernel.org/[email protected]
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Steven Rostedt (Google) <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Dan Carpenter authored and gregkh committed Aug 27, 2024
1 parent 6ccc060 commit 0cbf78d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions tools/tracing/rtla/src/osnoise_top.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,20 +520,17 @@ struct osnoise_tool *osnoise_init_top(struct osnoise_top_params *params)
return NULL;

tool->data = osnoise_alloc_top(nr_cpus);
if (!tool->data)
goto out_err;
if (!tool->data) {
osnoise_destroy_tool(tool);
return NULL;
}

tool->params = params;

tep_register_event_handler(tool->trace.tep, -1, "ftrace", "osnoise",
osnoise_top_handler, NULL);

return tool;

out_err:
osnoise_free_top(tool->data);
osnoise_destroy_tool(tool);
return NULL;
}

static int stop_tracing;
Expand Down

0 comments on commit 0cbf78d

Please sign in to comment.