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: stable@vger.kernel.org Cc: John Kacur <jkacur@redhat.com> Cc: "Luis Claudio R. Goncalves" <lgoncalv@redhat.com> Cc: Clark Williams <williams@redhat.com> Fixes: 1eceb2f ("rtla/osnoise: Add osnoise top mode") Link: https://lore.kernel.org/f964ed1f-64d2-4fde-ad3e-708331f8f358@stanley.mountain Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent d0949cd commit 90574d2

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

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)