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

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


The following commit(s) were added to refs/heads/releases/12.12 by this push:
     new cac1be9e74f tmpfs:fix memoryleak of tmpfs_opendir
cac1be9e74f is described below

commit cac1be9e74fcfcfb0c9f65cc8b83fbf5741030a7
Author: guohao15 <[email protected]>
AuthorDate: Tue Jul 8 17:34:30 2025 +0800

    tmpfs:fix memoryleak of tmpfs_opendir
    
    fix the memory leak in tmpfs_opendir
    
    Signed-off-by: guohao15 <[email protected]>
---
 fs/tmpfs/fs_tmpfs.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/tmpfs/fs_tmpfs.c b/fs/tmpfs/fs_tmpfs.c
index e4f5f25b320..42f7404e234 100644
--- a/fs/tmpfs/fs_tmpfs.c
+++ b/fs/tmpfs/fs_tmpfs.c
@@ -2047,14 +2047,18 @@ static int tmpfs_opendir(FAR struct inode *mountpt, FAR 
const char *relpath,
     {
       tdir->tf_tdo   = tdo;
       tdir->tf_index = tdo->tdo_nentries;
-
+      *dir = &tdir->tf_base;
       tmpfs_unlock_directory(tdo);
     }
 
   /* Release the lock on the file system and return the result */
 
   tmpfs_unlock(fs);
-  *dir = &tdir->tf_base;
+  if (ret < 0)
+    {
+      fs_heap_free(tdir);
+    }
+
   return ret;
 }
 

Reply via email to