public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [for-next][PATCH 0/4] rtla: Updates for 5.20
@ 2022-07-31 21:09 Steven Rostedt
  2022-07-31 21:09 ` [for-next][PATCH 1/4] rtla/utils: Use calloc and check the potential memory allocation failure Steven Rostedt
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Steven Rostedt @ 2022-07-31 21:09 UTC (permalink / raw)
  To: linux-kernel; +Cc: Daniel Bristot de Oliveira


Andreas Schwab (2):
      rtla: Fix double free
      rtla: Define syscall numbers for riscv

Daniel Bristot de Oliveira (1):
      rtla: Fix Makefile when called from -C tools/

jianchunfu (1):
      rtla/utils: Use calloc and check the potential memory allocation failure

----
 tools/tracing/rtla/Makefile    | 2 +-
 tools/tracing/rtla/src/trace.c | 9 +++++++--
 tools/tracing/rtla/src/utils.c | 7 ++++---
 3 files changed, 12 insertions(+), 6 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [for-next][PATCH 1/4] rtla/utils: Use calloc and check the potential memory allocation failure
  2022-07-31 21:09 [for-next][PATCH 0/4] rtla: Updates for 5.20 Steven Rostedt
@ 2022-07-31 21:09 ` Steven Rostedt
  2022-07-31 21:09 ` [for-next][PATCH 2/4] rtla: Fix Makefile when called from -C tools/ Steven Rostedt
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2022-07-31 21:09 UTC (permalink / raw)
  To: linux-kernel; +Cc: Daniel Bristot de Oliveira, jianchunfu

From: jianchunfu <jianchunfu@cmss.chinamobile.com>

Replace malloc with calloc and add memory allocating check
of mon_cpus before used.

Link: https://lkml.kernel.org/r/20220615073348.6891-1-jianchunfu@cmss.chinamobile.com

Fixes: 7d0dc9576dc3 ("rtla/timerlat: Add --dma-latency option")
Signed-off-by: jianchunfu <jianchunfu@cmss.chinamobile.com>
Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 tools/tracing/rtla/src/utils.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/tracing/rtla/src/utils.c b/tools/tracing/rtla/src/utils.c
index 5352167a1e75..5ae2fa96fde1 100644
--- a/tools/tracing/rtla/src/utils.c
+++ b/tools/tracing/rtla/src/utils.c
@@ -106,8 +106,9 @@ int parse_cpu_list(char *cpu_list, char **monitored_cpus)
 
 	nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
 
-	mon_cpus = malloc(nr_cpus * sizeof(char));
-	memset(mon_cpus, 0, (nr_cpus * sizeof(char)));
+	mon_cpus = calloc(nr_cpus, sizeof(char));
+	if (!mon_cpus)
+		goto err;
 
 	for (p = cpu_list; *p; ) {
 		cpu = atoi(p);
-- 
2.35.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [for-next][PATCH 2/4] rtla: Fix Makefile when called from -C tools/
  2022-07-31 21:09 [for-next][PATCH 0/4] rtla: Updates for 5.20 Steven Rostedt
  2022-07-31 21:09 ` [for-next][PATCH 1/4] rtla/utils: Use calloc and check the potential memory allocation failure Steven Rostedt
@ 2022-07-31 21:09 ` Steven Rostedt
  2022-07-31 21:09 ` [for-next][PATCH 3/4] rtla: Fix double free Steven Rostedt
  2022-07-31 21:09 ` [for-next][PATCH 4/4] rtla: Define syscall numbers for riscv Steven Rostedt
  3 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2022-07-31 21:09 UTC (permalink / raw)
  To: linux-kernel; +Cc: Daniel Bristot de Oliveira, Sedat Dilek

From: Daniel Bristot de Oliveira <bristot@kernel.org>

Sedat Dilek reported an error on rtla Makefile when running:

    $ make -C tools/ clean
    [...]
    make[2]: Entering directory
    '/home/dileks/src/linux-kernel/git/tools/tracing/rtla'
    [...]
    '/home/dileks/src/linux-kernel/git/Documentation/tools/rtla'
    /bin/sh: 1: test: rtla-make[2]:: unexpected operator    <------ The problem
    rm: cannot remove '/home/dileks/src/linux-kernel/git': Is a directory
    make[2]: *** [Makefile:120: clean] Error 1
    make[2]: Leaving directory

This occurred because the rtla calls kernel's Makefile to get the
version in silence mode, e.g.,

    $ make -sC ../../.. kernelversion
    5.19.0-rc4

But the -s is being ignored when rtla's makefile is called indirectly,
so the output looks like this:

    $ make -C ../../.. kernelversion
    make: Entering directory '/root/linux'
    5.19.0-rc4
    make: Leaving directory '/root/linux'

Using 'grep -v make' avoids this problem, e.g.,

    $ make -C ../../.. kernelversion | grep -v make
    5.19.0-rc4

Thus, add | grep -v make.

Link: https://lkml.kernel.org/r/870c02d4d97a921f02a31fa3b229fc549af61a20.1657747763.git.bristot@kernel.org

Fixes: 8619e32825fd ("rtla: Follow kernel version")
Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 tools/tracing/rtla/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/tracing/rtla/Makefile b/tools/tracing/rtla/Makefile
index 3822f4ea5f49..1bea2d16d4c1 100644
--- a/tools/tracing/rtla/Makefile
+++ b/tools/tracing/rtla/Makefile
@@ -1,6 +1,6 @@
 NAME	:=	rtla
 # Follow the kernel version
-VERSION :=	$(shell cat VERSION 2> /dev/null || make -sC ../../.. kernelversion)
+VERSION :=	$(shell cat VERSION 2> /dev/null || make -sC ../../.. kernelversion | grep -v make)
 
 # From libtracefs:
 # Makefiles suck: This macro sets a default value of $(2) for the
-- 
2.35.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [for-next][PATCH 3/4] rtla: Fix double free
  2022-07-31 21:09 [for-next][PATCH 0/4] rtla: Updates for 5.20 Steven Rostedt
  2022-07-31 21:09 ` [for-next][PATCH 1/4] rtla/utils: Use calloc and check the potential memory allocation failure Steven Rostedt
  2022-07-31 21:09 ` [for-next][PATCH 2/4] rtla: Fix Makefile when called from -C tools/ Steven Rostedt
@ 2022-07-31 21:09 ` Steven Rostedt
  2022-07-31 21:09 ` [for-next][PATCH 4/4] rtla: Define syscall numbers for riscv Steven Rostedt
  3 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2022-07-31 21:09 UTC (permalink / raw)
  To: linux-kernel; +Cc: Daniel Bristot de Oliveira, Andreas Schwab

From: Andreas Schwab <schwab@suse.de>

Avoid double free by making trace_instance_destroy indempotent.  When
trace_instance_init fails, it calls trace_instance_destroy, but its only
caller osnoise_destroy_tool calls it again.

Link: https://lkml.kernel.org/r/mvmilnlkyzx.fsf_-_@suse.de

Fixes: 0605bf009f18 ("rtla: Add osnoise tool")
Signed-off-by: Andreas Schwab <schwab@suse.de>
Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 tools/tracing/rtla/src/trace.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/tracing/rtla/src/trace.c b/tools/tracing/rtla/src/trace.c
index 5784c9f9e570..e1ba6d9f4265 100644
--- a/tools/tracing/rtla/src/trace.c
+++ b/tools/tracing/rtla/src/trace.c
@@ -134,13 +134,18 @@ void trace_instance_destroy(struct trace_instance *trace)
 	if (trace->inst) {
 		disable_tracer(trace->inst);
 		destroy_instance(trace->inst);
+		trace->inst = NULL;
 	}
 
-	if (trace->seq)
+	if (trace->seq) {
 		free(trace->seq);
+		trace->seq = NULL;
+	}
 
-	if (trace->tep)
+	if (trace->tep) {
 		tep_free(trace->tep);
+		trace->tep = NULL;
+	}
 }
 
 /*
-- 
2.35.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [for-next][PATCH 4/4] rtla: Define syscall numbers for riscv
  2022-07-31 21:09 [for-next][PATCH 0/4] rtla: Updates for 5.20 Steven Rostedt
                   ` (2 preceding siblings ...)
  2022-07-31 21:09 ` [for-next][PATCH 3/4] rtla: Fix double free Steven Rostedt
@ 2022-07-31 21:09 ` Steven Rostedt
  3 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2022-07-31 21:09 UTC (permalink / raw)
  To: linux-kernel; +Cc: Daniel Bristot de Oliveira, Andreas Schwab

From: Andreas Schwab <schwab@suse.de>

RISC-V uses the same (generic) syscall numbers as ARM64.

Link: https://lkml.kernel.org/r/mvma68wl2ul.fsf@suse.de

Signed-off-by: Andreas Schwab <schwab@suse.de>
Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 tools/tracing/rtla/src/utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/tracing/rtla/src/utils.c b/tools/tracing/rtla/src/utils.c
index 5ae2fa96fde1..663a047f794d 100644
--- a/tools/tracing/rtla/src/utils.c
+++ b/tools/tracing/rtla/src/utils.c
@@ -225,7 +225,7 @@ long parse_ns_duration(char *val)
 #elif __arm__
 # define __NR_sched_setattr	380
 # define __NR_sched_getattr	381
-#elif __aarch64__
+#elif __aarch64__ || __riscv
 # define __NR_sched_setattr	274
 # define __NR_sched_getattr	275
 #elif __powerpc__
-- 
2.35.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-07-31 21:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-31 21:09 [for-next][PATCH 0/4] rtla: Updates for 5.20 Steven Rostedt
2022-07-31 21:09 ` [for-next][PATCH 1/4] rtla/utils: Use calloc and check the potential memory allocation failure Steven Rostedt
2022-07-31 21:09 ` [for-next][PATCH 2/4] rtla: Fix Makefile when called from -C tools/ Steven Rostedt
2022-07-31 21:09 ` [for-next][PATCH 3/4] rtla: Fix double free Steven Rostedt
2022-07-31 21:09 ` [for-next][PATCH 4/4] rtla: Define syscall numbers for riscv Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox