Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 1eceb2fc2ca5 ("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>

authored by

Dan Carpenter and committed by
Steven Rostedt (Google)
90574d2a d0949cd4

+4 -7
+4 -7
tools/tracing/rtla/src/osnoise_top.c
··· 651 651 return NULL; 652 652 653 653 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 + } 656 658 657 659 tool->params = params; 658 660 ··· 662 660 osnoise_top_handler, NULL); 663 661 664 662 return tool; 665 - 666 - out_err: 667 - osnoise_free_top(tool->data); 668 - osnoise_destroy_tool(tool); 669 - return NULL; 670 663 } 671 664 672 665 static int stop_tracing;