[PATCH 4/7] test: self: ramfs: fix memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux