fs: pseudorename should call inode_release in the error path

to avoid the memory leak

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I8f7e4c8fb89188614d03dcf383a1707f25c65174
This commit is contained in:
Xiang Xiao 2021-07-09 15:46:02 +08:00 committed by Gustavo Henrique Nihei
parent 1e3a985155
commit 643ee82e9c
1 changed files with 3 additions and 0 deletions

View File

@ -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.