From 6367f2469c6068b3e06cad8aaa50f002aa16bdf9 Mon Sep 17 00:00:00 2001 From: dongjiuzhu1 Date: Fri, 8 Sep 2023 16:02:49 +0800 Subject: [PATCH] fs/vfs: fix dup issue for eventfd/signalfd/timerfd Signed-off-by: dongjiuzhu1 --- fs/vfs/fs_eventfd.c | 1 + fs/vfs/fs_signalfd.c | 2 ++ fs/vfs/fs_timerfd.c | 1 + 3 files changed, 4 insertions(+) diff --git a/fs/vfs/fs_eventfd.c b/fs/vfs/fs_eventfd.c index ac3287b4749..ff0a95db415 100644 --- a/fs/vfs/fs_eventfd.c +++ b/fs/vfs/fs_eventfd.c @@ -135,6 +135,7 @@ static FAR struct eventfd_priv_s *eventfd_allocdev(void) nxmutex_init(&dev->lock); nxmutex_lock(&dev->lock); + dev->crefs++; } return dev; diff --git a/fs/vfs/fs_signalfd.c b/fs/vfs/fs_signalfd.c index edb4992d003..5b702ae75ca 100644 --- a/fs/vfs/fs_signalfd.c +++ b/fs/vfs/fs_signalfd.c @@ -355,6 +355,8 @@ int signalfd(int fd, FAR const sigset_t *mask, int flags) ret = -fd; goto errout_with_dev; } + + dev->crefs++; } else { diff --git a/fs/vfs/fs_timerfd.c b/fs/vfs/fs_timerfd.c index fe5cf3cb3eb..f6486ae7880 100644 --- a/fs/vfs/fs_timerfd.c +++ b/fs/vfs/fs_timerfd.c @@ -146,6 +146,7 @@ static FAR struct timerfd_priv_s *timerfd_allocdev(void) nxmutex_init(&dev->lock); nxmutex_lock(&dev->lock); + dev->crefs++; } return dev;