fs_procfs:Fix closedir should handle the release dir handle on a case-by-case basis

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This commit is contained in:
chenrun1 2024-12-11 10:52:22 +08:00 committed by Xiang Xiao
parent b88aba5ddc
commit b973bf3191

View file

@ -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;
}
/****************************************************************************