diff --git a/fs/vfs/fs_symlink.c b/fs/vfs/fs_symlink.c index c06d231a890..552b1397774 100644 --- a/fs/vfs/fs_symlink.c +++ b/fs/vfs/fs_symlink.c @@ -146,6 +146,15 @@ int symlink(FAR const char *path1, FAR const char *path2) inode_lock(); ret = inode_reserve(path2, 0777, &inode); + + if (ret >= 0) + { + /* Initialize the inode */ + + INODE_SET_SOFTLINK(inode); + inode->u.i_link = newpath2; + } + inode_unlock(); if (ret < 0) { @@ -153,11 +162,6 @@ int symlink(FAR const char *path1, FAR const char *path2) errcode = -ret; goto errout_with_search; } - - /* Initialize the inode */ - - INODE_SET_SOFTLINK(inode); - inode->u.i_link = newpath2; } /* Symbolic link successfully created */