[SRU][J][PATCH 1/1] watch_queue: Use the bitmap API when applicable
Cengiz Can
cengiz.can at canonical.com
Thu Feb 13 14:04:35 UTC 2025
From: Christophe JAILLET <christophe.jaillet at wanadoo.fr>
Use bitmap_alloc() to simplify code, improve the semantic and reduce
some open-coded arithmetic in allocator arguments.
Also change a memset(0xff) into an equivalent bitmap_fill() to keep
consistency.
Signed-off-by: Christophe JAILLET <christophe.jaillet at wanadoo.fr>
Signed-off-by: David Howells <dhowells at redhat.com>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
(cherry picked from commit a66bd7575b5f449ee0ba20cfd21c3bc5b04ef361)
CVE-2022-0995
Signed-off-by: Cengiz Can <cengiz.can at canonical.com>
---
kernel/watch_queue.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c
index ae31bf8d2feb..7bd2322d6b6d 100644
--- a/kernel/watch_queue.c
+++ b/kernel/watch_queue.c
@@ -245,7 +245,6 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)
struct page **pages;
unsigned long *bitmap;
unsigned long user_bufs;
- unsigned int bmsize;
int ret, i, nr_pages;
if (!wqueue)
@@ -286,13 +285,11 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)
pages[i]->index = i * WATCH_QUEUE_NOTES_PER_PAGE;
}
- bmsize = (nr_notes + BITS_PER_LONG - 1) / BITS_PER_LONG;
- bmsize *= sizeof(unsigned long);
- bitmap = kmalloc(bmsize, GFP_KERNEL);
+ bitmap = bitmap_alloc(nr_notes, GFP_KERNEL);
if (!bitmap)
goto error_p;
- memset(bitmap, 0xff, bmsize);
+ bitmap_fill(bitmap, nr_notes);
wqueue->notes = pages;
wqueue->notes_bitmap = bitmap;
wqueue->nr_pages = nr_pages;
--
2.43.0
More information about the kernel-team
mailing list