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 94e9599e5cb48f6b2af76afe604906409064d340
Author: guohao15 <[email protected]>
AuthorDate: Fri Aug 2 14:22:32 2024 +0800

    file_lock:fix memory alloc/free not match
    
    Signed-off-by: guohao15 <[email protected]>
---
 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);
 }

Reply via email to