This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit c528244f19a282eb4d3c4266fcbf93c3367fc1b3 Author: chenrun1 <[email protected]> AuthorDate: Fri May 24 16:12:16 2024 +0800 fs_lock:Fixed the problem that in multi-threaded situations, the bucket may be deleted by other factors during the search process, resulting in assertion. hsearch_r(item = (key = 0x61492174,data = ?),action = ?, retval = 0x6266AC44, htab = 0x6159B758) H 1tem = Ckey = 0x61492174, data= : · action = ? retval = 0x6266AC44 htab = 0x6159B758 haad - 0x61616300 ie= 0×38 file_lock_find_bucket(inline) filepath = 0x61492174 hretvalue = 0x6055991D item = (key = 0x61492174, data = 0x0) Signed-off-by: chenrun1 <[email protected]> --- fs/vfs/fs_lock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/vfs/fs_lock.c b/fs/vfs/fs_lock.c index 82a5ec1e46..bfb430577b 100644 --- a/fs/vfs/fs_lock.c +++ b/fs/vfs/fs_lock.c @@ -767,15 +767,16 @@ void file_closelk(FAR struct file *filep) goto out; } + nxmutex_lock(&g_protect_lock); bucket = file_lock_find_bucket(path); if (bucket == NULL) { /* There is no bucket here, so we don't need to free it. */ + nxmutex_unlock(&g_protect_lock); goto out; } - nxmutex_lock(&g_protect_lock); list_for_every_entry_safe(&bucket->list, file_lock, temp, struct file_lock_s, fl_node) {
