imeghar2408-max opened a new pull request, #20038:
URL: https://github.com/apache/nuttx/pull/20038

   ## Summary
   
   Fix `inode_reserve()` to propagate inode search errors instead of
   continuing inode creation for every negative return from `inode_search()`.
   
   `inode_search()` returns `-ENOENT` when the path is valid but the target
   inode does not exist yet. Other negative returns indicate an actual
   lookup or path error, such as `-ENAMETOOLONG`.
   
   Previously, `inode_reserve()` continued processing any negative return.
   For an overlong pathname, this could leave the insertion metadata invalid
   and reach `inode_insert()` with a NULL parent, triggering an assertion.
   
   This change allows inode creation to continue only when
   `inode_search()` returns `-ENOENT`. All other errors are propagated
   through the existing cleanup path.
   
   ## Testing
   
   Tested with the NuttX simulator on Linux with ProcFS, TMPFS and ASan.
   
   Before the fix, an overlong pathname:
   
       mount -t tmpfs tmpfs 
/tmp/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
   
   triggered:
   
       Assertion failed parent != ((void*)0)
       at file: inode/fs_inodereserve.c:140
   
   After the fix, the same command returned:
   
       nsh: mount: mount failed: 36
   
   where 36 is `ENAMETOOLONG`, with no assertion or crash.
   
   A valid mount was also verified:
   
       mount -t tmpfs tmpfs /a
   
   which succeeded and appeared as:
   
       /a type tmpfs
   
   An existing inode case was also checked by creating `/a/b` twice; the
   second attempt returned `17` (`EEXIST`).
   
   `git diff --check` and `tools/checkpatch.sh -g HEAD` both pass.
   
   The separate `PATH_MAX` overflow case was not included as tested because
   the long NSH input could not be delivered reliably, so no claim is made
   for that case.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to