Skip to content

Commit 90574d2

Browse files
Dan Carpenterrostedt
authored andcommitted
rtla/osnoise: Prevent NULL dereference in error handling
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]>
1 parent d0949cd commit 90574d2

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

tools/tracing/rtla/src/osnoise_top.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -651,20 +651,17 @@ struct osnoise_tool *osnoise_init_top(struct osnoise_top_params *params)
651651
return NULL;
652652

653653
tool->data = osnoise_alloc_top(nr_cpus);
654-
if (!tool->data)
655-
goto out_err;
654+
if (!tool->data) {
655+
osnoise_destroy_tool(tool);
656+
return NULL;
657+
}
656658

657659
tool->params = params;
658660

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

662664
return tool;
663-
664-
out_err:
665-
osnoise_free_top(tool->data);
666-
osnoise_destroy_tool(tool);
667-
return NULL;
668665
}
669666

670667
static int stop_tracing;

0 commit comments

Comments
 (0)