From b973bf3191f1225f9850451ce8fb2340341d3557 Mon Sep 17 00:00:00 2001 From: chenrun1 Date: Wed, 11 Dec 2024 10:52:22 +0800 Subject: [PATCH] fs_procfs:Fix closedir should handle the release dir handle on a case-by-case basis Signed-off-by: chenrun1 --- fs/procfs/fs_procfs.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/fs/procfs/fs_procfs.c b/fs/procfs/fs_procfs.c index b0574c010b4..627d03e0e12 100644 --- a/fs/procfs/fs_procfs.c +++ b/fs/procfs/fs_procfs.c @@ -787,9 +787,24 @@ static int procfs_opendir(FAR struct inode *mountpt, FAR const char *relpath, static int procfs_closedir(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir) { + FAR struct procfs_dir_priv_s *dirpriv; + int ret = OK; + DEBUGASSERT(mountpt && dir); - fs_heap_free(dir); - return OK; + + dirpriv = (FAR struct procfs_dir_priv_s *)dir; + + if (dirpriv->procfsentry != NULL && + dirpriv->procfsentry->ops->closedir != NULL) + { + ret = dirpriv->procfsentry->ops->closedir(dir); + } + else + { + fs_heap_free(dir); + } + + return ret; } /****************************************************************************