realtime/librttest: get_numcpus() fix leak
PATCH 1/1 realtime/librttest: get_numcpus() fix leak
As pointed out on the mailing list this function has a memory leak, fixing it.
Signed-off-by Attila Fazekas <[email protected]>
--- testcases/realtime/lib/librttest.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
testcases/realtime/lib/librttest.c +4 -2
@@ -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; }
Signature · 5 lines
2.47.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Attila,
Quoted 2 lines
As pointed out on the mailing list this function has a memory leak, fixing it.
Good catch, thanks!
Reviewed-by Petr Vorel <[email protected]>
Actually old problem, IMHO:
Fixes 591c56b045 ("realtime/prio-preempt: take cpu isolation into consideration")
I'll wait little longer and merge.
Kind regards,
Petr
Quoted 25 lines
Signed-off-by Attila Fazekas <[email protected]>--- testcases/realtime/lib/librttest.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)testcases/realtime/lib/librttest.c +4
-2@@ -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; }
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Reviewed-by Cyril Hrubis <[email protected]>
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Attila, all,
thanks, fix merged!
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp