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; }