From c5619cb3fee900397d90bf64f5e4f5cffe375efb Mon Sep 17 00:00:00 2001 From: Megha Rajput Date: Tue, 1 Sep 2026 17:06:40 +0000 Subject: [PATCH] fs/inode: propagate inode search errors inode_reserve() previously continued processing all negative return values from inode_search(). Only -ENOENT indicates that the target inode is absent and creation may continue. Propagate other search errors through the existing cleanup path to avoid continuing inode creation with invalid insertion metadata. Assisted-by: GitHub Copilot Signed-off-by: Megha Rajput --- fs/inode/fs_inodereserve.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/inode/fs_inodereserve.c b/fs/inode/fs_inodereserve.c index 3082a523b97..1b3c970e7e1 100644 --- a/fs/inode/fs_inodereserve.c +++ b/fs/inode/fs_inodereserve.c @@ -53,6 +53,7 @@ static ino_t g_ino; static int inode_namelen(FAR const char *name) { FAR const char *tmp = name; + while (*tmp && *tmp != '/') { tmp++; @@ -210,13 +211,17 @@ int inode_reserve(FAR const char *path, SETUP_SEARCH(&desc, path, false); ret = inode_search(&desc); - if (ret >= 0) + if (ret != -ENOENT) { /* It is an error if the node already exists in the tree (or if it * lies within a mountpoint, we don't distinguish here). */ - ret = -EEXIST; + if (ret >= 0) + { + ret = -EEXIST; + } + goto errout_with_search; } @@ -249,6 +254,7 @@ int inode_reserve(FAR const char *path, */ FAR const char *nextname = inode_nextname(name); + if (*nextname != '\0') { /* Insert an operationless node */