inotify:fix memory alloc/free not match

Signed-off-by: guohao15 <guohao15@xiaomi.com>
This commit is contained in:
guohao15 2024-08-02 11:57:07 +08:00 committed by Xiang Xiao
parent c63adb5c14
commit 76a1a5b2c4

View file

@ -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)
{