All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Avinesh Kumar <akumar@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] syscalls/pipe06: Rewrite the test using new LTP API
Date: Tue, 18 Jul 2023 10:23:13 +0200	[thread overview]
Message-ID: <20230718082313.GA1140910@pevik> (raw)
In-Reply-To: <20230717153339.11904-1-akumar@suse.de>

Hi Avinesh,

>  testcases/kernel/syscalls/pipe/pipe06.c | 133 ++++++------------------
...
> +static void setup(void)
>  {
> +	int max_fds;

> -		/* reset tst_count in case we are looping */
> -		tst_count = 0;
> +	max_fds = getdtablesize();
> +	tst_res(TINFO, "getdtablesize() = %d", max_fds);
> +	opened_fds = SAFE_MALLOC(max_fds * sizeof(int));
You don't free opened_fds in cleanup, that would be a memory leak.
...

> +static void cleanup(void)
>  {
> +	for (int i = 0; i < num_opened_fds; i++)
> +		SAFE_CLOSE(opened_fds[i]);
>  }
> +
> +static struct tst_test test = {
> +	.setup = setup,
> +	.cleanup = cleanup,
> +	.test_all = run
> +};

I suggest to fix it with patch below.
With that:
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

+++ testcases/kernel/syscalls/pipe/pipe06.c
@@ -12,6 +12,7 @@
  * limit on the number of open file descriptors has been reached.
  */
 
+#include <stdlib.h>
 #include "tst_test.h"
 
 static int fds[2];
@@ -43,6 +44,9 @@ static void cleanup(void)
 {
 	for (int i = 0; i < num_opened_fds; i++)
 		SAFE_CLOSE(opened_fds[i]);
+
+	if (opened_fds)
+		free(opened_fds);
 }
 
 static struct tst_test test = {

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2023-07-18  8:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-17 15:33 [LTP] [PATCH] syscalls/pipe06: Rewrite the test using new LTP API Avinesh Kumar
2023-07-18  8:23 ` Petr Vorel [this message]
2023-07-18  9:27   ` Avinesh Kumar

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=20230718082313.GA1140910@pevik \
    --to=pvorel@suse.cz \
    --cc=akumar@suse.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.