public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Attila Fazekas <afazekas@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] realtime/librttest: get_numcpus() fix leak
Date: Thu, 23 Jan 2025 13:08:22 +0100	[thread overview]
Message-ID: <20250123120822.GA81149@pevik> (raw)
In-Reply-To: <20250123111854.28412-1-afazekas@redhat.com>

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

  reply	other threads:[~2025-01-23 12:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-23 11:18 [LTP] [PATCH] realtime/librttest: get_numcpus() fix leak Attila Fazekas
2025-01-23 12:08 ` Petr Vorel [this message]
2025-01-23 14:22 ` Cyril Hrubis
2025-01-23 18:18   ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250123120822.GA81149@pevik \
    --to=pvorel@suse.cz \
    --cc=afazekas@redhat.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox