mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 4/7] test: self: ramfs: fix memory leak
Date: Fri, 17 May 2024 09:48:21 +0200	[thread overview]
Message-ID: <20240517074824.767767-4-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240517074824.767767-1-a.fatoum@pengutronix.de>

Like many other tests, ramfs also leaks memory. Fix this.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 test/self/ramfs.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/test/self/ramfs.c b/test/self/ramfs.c
index 1bc2b3b068f0..239e3e690740 100644
--- a/test/self/ramfs.c
+++ b/test/self/ramfs.c
@@ -58,7 +58,7 @@ static void test_ramfs(void)
 	char *content = NULL;
 	char *oldpwd = NULL;
 	DIR *dir = NULL;
-	const char *dname;
+	char *dname;
 	struct stat st;
 	int i, j, ret, fd;
 	struct dirent *d;
@@ -196,6 +196,8 @@ static void test_ramfs(void)
 			expect_success(memcmp(buf, ARRAY_AND_SIZE(hello)),
 				       "read_file() content");
 		}
+
+		free(buf);
 	}
 
 out:
@@ -209,5 +211,6 @@ static void test_ramfs(void)
 
 	dir = opendir(dname);
 	expect_fail(dir ? 0 : -EISDIR, "opening removed directory");
+	free(dname);
 }
 bselftest(core, test_ramfs);
-- 
2.39.2




  parent reply	other threads:[~2024-05-17  7:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-17  7:48 [PATCH 1/7] of: free unflattened overlays after application Ahmad Fatoum
2024-05-17  7:48 ` [PATCH 2/7] of: overlay: do not leak fixed up path Ahmad Fatoum
2024-05-17  7:48 ` [PATCH 3/7] test: self: digest: don't leak digest buffers Ahmad Fatoum
2024-05-17  7:48 ` Ahmad Fatoum [this message]
2024-05-17  7:48 ` [PATCH 5/7] regulator: of_regulator: remove unused allocation Ahmad Fatoum
2024-05-21  6:30   ` Sascha Hauer
2024-05-17  7:48 ` [PATCH 6/7] globalvar: fix memory leak Ahmad Fatoum
2024-05-17  7:48 ` [PATCH 7/7] power: reset: reboot-mode: " Ahmad Fatoum
2024-05-21  6:29 ` [PATCH 1/7] of: free unflattened overlays after application Sascha Hauer

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=20240517074824.767767-4-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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