[PATCH 2/2] watch_queue: Fix a memory leak

From: Christophe JAILLET
Date: Sun Nov 28 2021 - 09:00:40 EST


The 'notes_bitmap' is allocated in 'watch_queue_set_size()' but is never
released.
Free it when 'wqueue' and its other fields are freed.

Fixes: c73be61cede5 ("pipe: Add general notification queue support")
Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
WARNING: This patch is certainly buggy because there is 'rcu'
consideration, but I've nothing better to propose.

It is maybe also completely buggy because freeing reference counted
resources is sometimes puzzling!

So review with care and update as needed (if needed :) )
---
kernel/watch_queue.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c
index 41ea30948c57..36c6822bec86 100644
--- a/kernel/watch_queue.c
+++ b/kernel/watch_queue.c
@@ -372,6 +372,7 @@ static void __put_watch_queue(struct kref *kref)
wfilter = rcu_access_pointer(wqueue->filter);
if (wfilter)
kfree_rcu(wfilter, rcu);
+ bitmap_free(wqueue->notes_bitmap);
kfree_rcu(wqueue, rcu);
}

--
2.30.2