From 01bfa1a5007cfc416750eacd28b749e8830edfde Mon Sep 17 00:00:00 2001 From: Michal Lenc Date: Mon, 16 Jun 2025 09:38:13 +0200 Subject: [PATCH] fs/vfs/fs_close.c: avoid double free if CONFIG_FS_NOTIFY is set Double free occurred in lib_put_pathbuffer if CONFIG_FS_NOTIFY option was enabled. The second if statement has to be called only if the close operation returned error. The bug was introduced in 14f5c48 and was causing misc/lib_tempbuffer.c:141 debug assertion. Signed-off-by: Michal Lenc --- fs/vfs/fs_close.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/vfs/fs_close.c b/fs/vfs/fs_close.c index 980df65585..b7b5cee751 100644 --- a/fs/vfs/fs_close.c +++ b/fs/vfs/fs_close.c @@ -139,9 +139,8 @@ int file_close(FAR struct file *filep) inode_release(inode); } - #ifdef CONFIG_FS_NOTIFY - if (path != NULL) + else if (path != NULL) { lib_put_pathbuffer(path); }