From e6eddfa71127699d613147bba44279bfe7c61196 Mon Sep 17 00:00:00 2001 From: zmq810150896 <50894086+zmq810150896@users.noreply.github.com> Date: Thu, 12 Oct 2023 08:22:46 +0800 Subject: [PATCH] Fix the problem that when dfs_v2 transmits fd, dentry or vnode does not exist (#8089) --- components/lwp/lwp_ipc.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/components/lwp/lwp_ipc.c b/components/lwp/lwp_ipc.c index 0b36306057..8410bc2cac 100644 --- a/components/lwp/lwp_ipc.c +++ b/components/lwp/lwp_ipc.c @@ -407,19 +407,26 @@ static int _ipc_msg_fd_new(void *file) return -1; } -#ifdef RT_USING_DFS_V2 - d->fops = df->fops; - d->mode = df->mode; - d->dentry = df->dentry; - d->dentry->ref_count ++; -#endif - d->vnode = df->vnode; d->flags = df->flags; d->data = df->data; d->magic = df->magic; - d->vnode->ref_count ++; +#ifdef RT_USING_DFS_V2 + d->fops = df->fops; + d->mode = df->mode; + d->dentry = df->dentry; + if (d->dentry) + rt_atomic_add(&(d->dentry->ref_count), 1); + + if (d->vnode) + rt_atomic_add(&(d->vnode->ref_count), 1); +#else + if (d->vnode) + d->vnode->ref_count ++; +#endif + + return fd; }