From a431bb45791993bd6e6239b6621aa09ee43558c1 Mon Sep 17 00:00:00 2001 From: LiPeng Date: Fri, 15 Sep 2023 23:49:20 +0800 Subject: [PATCH] fix(vfs): Fix event_write may not exit critical section This commit fixes the event_write() function where the critical section was unbalanced. Merges https://github.com/espressif/esp-idf/pull/12258 --- components/vfs/vfs_eventfd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/vfs/vfs_eventfd.c b/components/vfs/vfs_eventfd.c index a4f088352b47..11ff2fb7e7c0 100644 --- a/components/vfs/vfs_eventfd.c +++ b/components/vfs/vfs_eventfd.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -267,14 +267,14 @@ static ssize_t event_write(int fd, const void *data, size_t size) s_events[fd].value += *val; ret = size; trigger_select_for_event(&s_events[fd]); - - if (s_events[fd].support_isr) { - portEXIT_CRITICAL(&s_events[fd].data_spin_lock); - } } else { errno = EBADF; ret = -1; } + + if (s_events[fd].support_isr) { + portEXIT_CRITICAL(&s_events[fd].data_spin_lock); + } _lock_release_recursive(&s_events[fd].lock); } return ret;