From 1cc67b68f246e0a077118c1d8ebf9ace0024f3e6 Mon Sep 17 00:00:00 2001 From: dongjiuzhu1 Date: Mon, 5 Jun 2023 18:09:04 +0800 Subject: [PATCH] fs/procfs: call the close of each component when procfs_close Signed-off-by: dongjiuzhu1 --- fs/procfs/fs_procfs.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/procfs/fs_procfs.c b/fs/procfs/fs_procfs.c index 74cd06924a..638b72f77b 100644 --- a/fs/procfs/fs_procfs.c +++ b/fs/procfs/fs_procfs.c @@ -421,6 +421,7 @@ static int procfs_open(FAR struct file *filep, FAR const char *relpath, static int procfs_close(FAR struct file *filep) { FAR struct procfs_file_s *attr; + int ret = OK; /* Recover our private data from the struct file instance */ @@ -429,9 +430,17 @@ static int procfs_close(FAR struct file *filep) /* Release the file attributes structure */ - kmm_free(attr); + if (attr->procfsentry->ops->close != NULL) + { + ret = attr->procfsentry->ops->close(filep); + } + else + { + kmm_free(attr); + } + filep->f_priv = NULL; - return OK; + return ret; } /****************************************************************************