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

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


The following commit(s) were added to refs/heads/master by this push:
     new 435692be2d4 fs/vfs: Release inode unconditionally in file_close().
435692be2d4 is described below

commit 435692be2d42edcb13e95028073cf078978fc8c9
Author: Sarthak Pandey <[email protected]>
AuthorDate: Sun Nov 29 00:08:34 2026 +0530

    fs/vfs: Release inode unconditionally in file_close().
    
    In file_close(), if the underlying driver close operation returns an error 
(ret < 0), inode_release(inode) was skipped while filep->f_inode was 
unconditionally set to NULL. This left the inode reference count permanently 
elevated and leaked the inode, causing subsequent umount operations to fail 
with -EBUSY.
    
    This commit ensures inode_release(inode) is called unconditionally upon 
file_close(), adhering to POSIX close semantics where descriptor resources and 
inode associations are released regardless of driver flush/close status.
    
    Fixes #22528
    
    Assisted-by: Antigravity:gemini-3.8-flash
    Signed-off-by: Sarthak Pandey <[email protected]>
---
 fs/vfs/fs_close.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/fs/vfs/fs_close.c b/fs/vfs/fs_close.c
index 4f87712cab4..5c748bbb96f 100644
--- a/fs/vfs/fs_close.c
+++ b/fs/vfs/fs_close.c
@@ -132,27 +132,21 @@ int file_close(FAR struct file *filep)
                           g_fs_profile.closes);
         }
 
-      /* And release the inode */
-
-      if (ret >= 0)
-        {
 #ifdef CONFIG_FS_NOTIFY
-          if (path != NULL)
+      if (path != NULL)
+        {
+          if (ret >= 0)
             {
               notify_close(path, filep->f_oflags);
-              lib_put_pathbuffer(path);
             }
-#endif
 
-          inode_release(inode);
-        }
-#ifdef CONFIG_FS_NOTIFY
-      else if (path != NULL)
-        {
           lib_put_pathbuffer(path);
         }
 #endif
 
+      /* And release the inode */
+
+      inode_release(inode);
       filep->f_inode = NULL;
     }
 

Reply via email to