Skip to content

Commit 3b4c037

Browse files
dhowellstorvalds
authored andcommitted
watch_queue: Fix the alloc bitmap size to reflect notes allocated
Currently, watch_queue_set_size() sets the number of notes available in wqueue->nr_notes according to the number of notes allocated, but sets the size of the bitmap to the unrounded number of notes originally asked for. Fix this by setting the bitmap size to the number of notes we're actually going to make available (ie. the number allocated). Fixes: c73be61 ("pipe: Add general notification queue support") Reported-by: Jann Horn <jannh@google.com> Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent a66bd75 commit 3b4c037

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

kernel/watch_queue.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)
243243
goto error;
244244
}
245245

246+
nr_notes = nr_pages * WATCH_QUEUE_NOTES_PER_PAGE;
246247
ret = pipe_resize_ring(pipe, roundup_pow_of_two(nr_notes));
247248
if (ret < 0)
248249
goto error;
@@ -266,7 +267,7 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)
266267
wqueue->notes = pages;
267268
wqueue->notes_bitmap = bitmap;
268269
wqueue->nr_pages = nr_pages;
269-
wqueue->nr_notes = nr_pages * WATCH_QUEUE_NOTES_PER_PAGE;
270+
wqueue->nr_notes = nr_notes;
270271
return 0;
271272

272273
error_p:

0 commit comments

Comments
 (0)