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 76a1a5b2c426db996a427892837abf83fe44f505
Author: guohao15 <[email protected]>
AuthorDate: Fri Aug 2 11:57:07 2024 +0800

    inotify:fix memory alloc/free not match
    
    Signed-off-by: guohao15 <[email protected]>
---
 fs/notify/inotify.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/fs/notify/inotify.c b/fs/notify/inotify.c
index d621f42ebd..84f20853e3 100644
--- a/fs/notify/inotify.c
+++ b/fs/notify/inotify.c
@@ -1009,6 +1009,22 @@ static inline void notify_queue_filep_event(FAR struct 
file *filep,
   nxmutex_unlock(&g_inotify.lock);
 }
 
+/****************************************************************************
+ * Name: notify_free_entry
+ *
+ * Description:
+ *   Deallocate the hash entry.
+ *
+ ****************************************************************************/
+
+static void notify_free_entry(FAR ENTRY *entry)
+{
+  /* Key is alloced by lib_malloc, value is alloced by kmm_malloc */
+
+  lib_free(entry->key);
+  kmm_free(entry->data);
+}
+
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -1276,6 +1292,7 @@ void notify_initialize(void)
 {
   int ret;
 
+  g_inotify.hash.free_entry = notify_free_entry;
   ret = hcreate_r(CONFIG_FS_NOTIFY_BUCKET_SIZE, &g_inotify.hash);
   if (ret != 1)
     {

Reply via email to