From 643ee82e9c67b8f4b4e0b28da73d3225c20b6237 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Fri, 9 Jul 2021 15:46:02 +0800 Subject: [PATCH] fs: pseudorename should call inode_release in the error path to avoid the memory leak Signed-off-by: Xiang Xiao Change-Id: I8f7e4c8fb89188614d03dcf383a1707f25c65174 --- fs/vfs/fs_rename.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/vfs/fs_rename.c b/fs/vfs/fs_rename.c index ad90d6edce..173d26f525 100644 --- a/fs/vfs/fs_rename.c +++ b/fs/vfs/fs_rename.c @@ -89,6 +89,7 @@ next_subdir: if (oldinode == newinode) { + inode_release(newinode); ret = OK; goto errout; /* Bad naming, this is not an error case. */ } @@ -113,6 +114,8 @@ next_subdir: FAR char *subdirname; FAR char *tmp; + inode_release(newinode); + /* Yes.. In this case, the target of the rename must be a * subdirectory of newinode, not the newinode itself. For * example: mv b a/ must move b to a/b.