* [LTP] [PATCH] realtime/librttest: get_numcpus() fix leak
@ 2025-01-23 11:18 Attila Fazekas
2025-01-23 12:08 ` Petr Vorel
2025-01-23 14:22 ` Cyril Hrubis
0 siblings, 2 replies; 4+ messages in thread
From: Attila Fazekas @ 2025-01-23 11:18 UTC (permalink / raw)
To: ltp; +Cc: Attila Fazekas
As pointed out on the mailing list this function has
a memory leak, fixing it.
Signed-off-by: Attila Fazekas <afazekas@redhat.com>
---
testcases/realtime/lib/librttest.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/testcases/realtime/lib/librttest.c b/testcases/realtime/lib/librttest.c
index 03566f36d..99ce78b33 100644
--- a/testcases/realtime/lib/librttest.c
+++ b/testcases/realtime/lib/librttest.c
@@ -768,11 +768,13 @@ int get_numcpus(void)
{
long numcpus_conf = sysconf(_SC_NPROCESSORS_CONF);
size_t size = CPU_ALLOC_SIZE(numcpus_conf);
+ int cpu_count;
cpu_set_t *cpuset = CPU_ALLOC(numcpus_conf);
CPU_ZERO_S(size, cpuset);
/* Get the number of cpus accessible to the current process */
sched_getaffinity(0, size, cpuset);
-
- return CPU_COUNT_S(size, cpuset);
+ cpu_count = CPU_COUNT_S(size, cpuset);
+ CPU_FREE(cpuset);
+ return cpu_count;
}
--
2.47.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH] realtime/librttest: get_numcpus() fix leak
2025-01-23 11:18 [LTP] [PATCH] realtime/librttest: get_numcpus() fix leak Attila Fazekas
@ 2025-01-23 12:08 ` Petr Vorel
2025-01-23 14:22 ` Cyril Hrubis
1 sibling, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2025-01-23 12:08 UTC (permalink / raw)
To: Attila Fazekas; +Cc: ltp
Hi Attila,
> As pointed out on the mailing list this function has
> a memory leak, fixing it.
Good catch, thanks!
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Actually old problem, IMHO:
Fixes: 591c56b045 ("realtime/prio-preempt: take cpu isolation into consideration")
I'll wait little longer and merge.
Kind regards,
Petr
> Signed-off-by: Attila Fazekas <afazekas@redhat.com>
> ---
> testcases/realtime/lib/librttest.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
> diff --git a/testcases/realtime/lib/librttest.c b/testcases/realtime/lib/librttest.c
> index 03566f36d..99ce78b33 100644
> --- a/testcases/realtime/lib/librttest.c
> +++ b/testcases/realtime/lib/librttest.c
> @@ -768,11 +768,13 @@ int get_numcpus(void)
> {
> long numcpus_conf = sysconf(_SC_NPROCESSORS_CONF);
> size_t size = CPU_ALLOC_SIZE(numcpus_conf);
> + int cpu_count;
> cpu_set_t *cpuset = CPU_ALLOC(numcpus_conf);
> CPU_ZERO_S(size, cpuset);
> /* Get the number of cpus accessible to the current process */
> sched_getaffinity(0, size, cpuset);
> -
> - return CPU_COUNT_S(size, cpuset);
> + cpu_count = CPU_COUNT_S(size, cpuset);
> + CPU_FREE(cpuset);
> + return cpu_count;
> }
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH] realtime/librttest: get_numcpus() fix leak
2025-01-23 11:18 [LTP] [PATCH] realtime/librttest: get_numcpus() fix leak Attila Fazekas
2025-01-23 12:08 ` Petr Vorel
@ 2025-01-23 14:22 ` Cyril Hrubis
2025-01-23 18:18 ` Petr Vorel
1 sibling, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2025-01-23 14:22 UTC (permalink / raw)
To: Attila Fazekas; +Cc: ltp
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH] realtime/librttest: get_numcpus() fix leak
2025-01-23 14:22 ` Cyril Hrubis
@ 2025-01-23 18:18 ` Petr Vorel
0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2025-01-23 18:18 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp, Attila Fazekas
Hi Attila, all,
thanks, fix merged!
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-23 18:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-23 11:18 [LTP] [PATCH] realtime/librttest: get_numcpus() fix leak Attila Fazekas
2025-01-23 12:08 ` Petr Vorel
2025-01-23 14:22 ` Cyril Hrubis
2025-01-23 18:18 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox