Skip to content

Commit 76a1a5b

Browse files
guohao15xiaoxiang781216
authored andcommitted
inotify:fix memory alloc/free not match
Signed-off-by: guohao15 <[email protected]>
1 parent c63adb5 commit 76a1a5b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

fs/notify/inotify.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,22 @@ static inline void notify_queue_filep_event(FAR struct file *filep,
10091009
nxmutex_unlock(&g_inotify.lock);
10101010
}
10111011

1012+
/****************************************************************************
1013+
* Name: notify_free_entry
1014+
*
1015+
* Description:
1016+
* Deallocate the hash entry.
1017+
*
1018+
****************************************************************************/
1019+
1020+
static void notify_free_entry(FAR ENTRY *entry)
1021+
{
1022+
/* Key is alloced by lib_malloc, value is alloced by kmm_malloc */
1023+
1024+
lib_free(entry->key);
1025+
kmm_free(entry->data);
1026+
}
1027+
10121028
/****************************************************************************
10131029
* Public Functions
10141030
****************************************************************************/
@@ -1276,6 +1292,7 @@ void notify_initialize(void)
12761292
{
12771293
int ret;
12781294

1295+
g_inotify.hash.free_entry = notify_free_entry;
12791296
ret = hcreate_r(CONFIG_FS_NOTIFY_BUCKET_SIZE, &g_inotify.hash);
12801297
if (ret != 1)
12811298
{

0 commit comments

Comments
 (0)