From 94e9599e5cb48f6b2af76afe604906409064d340 Mon Sep 17 00:00:00 2001 From: guohao15 Date: Fri, 2 Aug 2024 14:22:32 +0800 Subject: [PATCH] file_lock:fix memory alloc/free not match Signed-off-by: guohao15 --- fs/vfs/fs_lock.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fs/vfs/fs_lock.c b/fs/vfs/fs_lock.c index 25e63e8c36..9ebafbe860 100644 --- a/fs/vfs/fs_lock.c +++ b/fs/vfs/fs_lock.c @@ -292,6 +292,16 @@ file_lock_find_bucket(FAR const char *filepath) return NULL; } +/**************************************************************************** + * Name: file_lock_free_entry + ****************************************************************************/ + +static void file_lock_free_entry(FAR ENTRY *entry) +{ + lib_free(entry->key); + kmm_free(entry->data); +} + /**************************************************************************** * Name: file_lock_create_bucket ****************************************************************************/ @@ -824,5 +834,6 @@ void file_initlk(void) { /* Initialize file lock context hash table */ + g_file_lock_table.free_entry = file_lock_free_entry; hcreate_r(CONFIG_FS_LOCK_BUCKET_SIZE, &g_file_lock_table); }