This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch releases/13.1
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/releases/13.1 by this push:
     new b1df11bbce2 fs/inode: propagate inode search errors
b1df11bbce2 is described below

commit b1df11bbce2034c6a2221fb9fc202d7efc937b33
Author: Megha Rajput <[email protected]>
AuthorDate: Tue Sep 1 17:06:40 2026 +0000

    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 <[email protected]>
---
 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 */

Reply via email to