fs/epoll: release refs count of teardown/oneshot to avoid fd leak on close

When an epoll fd is closed, the file descriptors in the teardown and
oneshot lists were not being properly dereferenced, leading to fd leaks.

This fix ensures that all fds in the teardown and oneshot lists are
properly released via file_put() during epoll_do_close(), matching the
behavior for fds in the setup list.

Impact:
- Prevents fd leaks when epoll fd is closed
- Ensures proper cleanup of all tracked file descriptors
- Critical for applications using EPOLLONESHOT or fd removal operations

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
dongjiuzhu1
2025-12-08 22:17:05 +08:00
committed by Alan C. Assis
parent 8c0850b0bd
commit 61a2ab98ef
+10
View File
@@ -203,6 +203,16 @@ static int epoll_do_close(FAR struct file *filep)
file_put(epn->filep);
}
list_for_every_entry(&eph->teardown, epn, epoll_node_t, node)
{
file_put(epn->filep);
}
list_for_every_entry(&eph->oneshot, epn, epoll_node_t, node)
{
file_put(epn->filep);
}
list_for_every_entry_safe(&eph->extend, epn, tmp, epoll_node_t, node)
{
list_delete(&epn->node);