Sarthak-Pandey opened a new pull request, #22547:
URL: https://github.com/apache/nuttx/pull/22547

   ## Summary
   
   * **Why change is necessary:** In `file_close()`, if the underlying 
driver/filesystem's `close` callback (`inode->u.i_ops->close`) returns an error 
(`ret < 0`), `inode_release(inode)` was skipped because it was guarded by `if 
(ret >= 0)`. However, `filep->f_inode = NULL` was executed unconditionally, 
leaving `inode->i_crefs` permanently elevated and leaking the inode. This 
prevents subsequent `umount()` calls from succeeding, failing with `-EBUSY`.
   * **What functional part of the code is being changed:** `fs/vfs/fs_close.c`
   * **How does the change work:** Moves `inode_release(inode)` outside the `if 
(ret >= 0)` condition so the inode reference is always released upon close, 
adhering to POSIX close semantics. Also cleans up the `CONFIG_FS_NOTIFY` path 
buffer handling.
   * **Related NuttX Issue:** Fixes #22528
   
   ## Impact
   
   * Is new feature added? Is existing feature changed? NO
   * Impact on user: NO (No application code changes required. Fixes unexpected 
`-EBUSY` when unmounting filesystems after driver close errors.)
   * Impact on build: NO
   * Impact on hardware: NO
   * Impact on documentation: NO
   * Impact on security: NO
   * Impact on compatibility: NO (Fully backward compatible)
   * Impact on stability: YES (Eliminates permanent inode reference leaks and 
unmount failures on driver errors)
   
   ## Testing
   
   I confirm that changes are verified on local setup and works as intended:
   * Build Host: Windows 11, x86_64, GCC
   * Target: `sim`
   
   Testing verification:
   * Coding style verified with `tools/nxstyle fs/vfs/fs_close.c`: 0 errors, 0 
warnings.
   * Compilation syntax verified with GCC for both `CONFIG_FS_NOTIFY` enabled 
and disabled configurations (`COMPILATION_SUCCESS`).
   
   ## PR verification Self-Check
   
   * [x] This PR introduces only one functional change.
   * [x] I have updated all required description fields above.
   * [x] My PR adheres to Contributing Guidelines and Documentation.
   * [ ] My PR is still work in progress (not ready for review).
   * [x] My PR is ready for review and can be safely merged into a codebase.


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

  • [PR] fs/vfs: Release inode un... Sarthak-Pandey (via GitHub) via commits

Reply via email to