arnavsharma990 opened a new pull request, #21117:
URL: https://github.com/apache/nuttx/pull/21117

   ## Summary
   
   When `O_NOFOLLOW` is specified and the resolved inode is a symbolic link, 
`file_vopen()` returns `-ELOOP` directly. At this point, `inode_find()` has 
acquired an inode reference and `inode_search_setup()` has initialized the 
search descriptor. Returning directly bypasses the established cleanup path 
(`errout_with_inode` / `errout_with_search`), potentially leaving both 
resources unreleased.
   
   Route the error through `errout_with_inode` so the inode reference and 
search descriptor are released by the existing cleanup sequence. This is a 
minimal, single-file change with no unrelated refactoring or altered error 
semantics.
   
   Fixes #21116
   
   ## Impact
   
   - **Users:** Prevents potential resource leaks when an `O_NOFOLLOW` open 
fails with `ELOOP` for a symbolic link.
   - **Build process:** No new Kconfig options or dependencies.
   - **Hardware:** No hardware-specific changes; this is 
architecture-independent VFS code.
   - **Documentation:** No documentation changes required.
   - **Security and robustness:** Improves resource cleanup on an error path.
   - **Compatibility:** No API or ABI changes. Opening a symbolic link with 
`O_NOFOLLOW` continues to fail with `ELOOP`.
   
   ## Testing
   
   - `tools/nxstyle fs/vfs/fs_open.c`: passed with no violations.
   - `git diff --cached --check`: passed with no whitespace errors.
   - **Targeted build (`sim:nsh`):** `fs/vfs/fs_open.c` compiled into 
`build/fs/libfs.a`; no errors were attributed to the modified source file.
   - **Regression test:** A focused test was added in the separate 
`apache/nuttx-apps` repository at 
`testing/testsuites/kernel/fs/cases/fs_nofollow_test.c`. It compiled with 
`-Wall -Werror` and checks that opening a symbolic link with `O_NOFOLLOW` fails 
with `ELOOP`. Runtime execution has not been completed.
   - **Full builds:** The `sim:nsh` and `sim:citest` builds did not complete 
because of environment/toolchain issues, including `nshlib` 
implicit-declaration errors, an LTP context download failure, and a missing 
`cxxabi.h`. These failures have not been attributed to this change.
   - **Host environment:** macOS, Darwin 25.6.0, arm64, clang toolchain. 
Configuration: `sim:citest-dirty` with `CONFIG_FS_LINKS=y` and 
`CONFIG_CM_FS_TEST=y`. No hardware testing performed.
   
   Runtime validation remains outstanding.


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