[RFC PATCH 2/2] fs: fix chdir()

Antony Pavlov antonynpavlov at gmail.com
Tue Oct 18 05:48:45 EDT 2011


chdir() allocates memory using mormalise_path(). But if path_check_prereq()
returns error than memory isn't freed.

Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
 fs/fs.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index 714fc9b..f42ca36 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -347,8 +347,9 @@ int chdir(const char *pathname)
 
 	strcpy(cwd, p);
 
-	free(p);
 out:
+	free(p);
+
 	return errno;
 }
 EXPORT_SYMBOL(chdir);
-- 
1.7.6.3




More information about the barebox mailing list