linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/gup.c: Handling ERR within unpin_user_pages()
@ 2020-09-13 14:32 Souptick Joarder
  2020-09-13 14:55 ` Matthew Wilcox
  0 siblings, 1 reply; 7+ messages in thread
From: Souptick Joarder @ 2020-09-13 14:32 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, Souptick Joarder, John Hubbard

It is possible that a buggy caller of unpin_user_pages()
(specially in error handling path) may end up calling it with
npages < 0 which is unnecessary.

This can be fixed by adding extra check inside unpin_user_pages().

Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Cc: John Hubbard <jhubbard@nvidia.com>
---
 mm/gup.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/gup.c b/mm/gup.c
index 0b5c308b..2e19bd6 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -328,6 +328,9 @@ void unpin_user_pages(struct page **pages, unsigned long npages)
 {
 	unsigned long index;
 
+	if (WARN_ON_ONCE(npages < 0))
+		return;
+
 	/*
 	 * TODO: this can be optimized for huge pages: if a series of pages is
 	 * physically contiguous and part of the same compound page, then a
-- 
1.9.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-09-14 21:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-13 14:32 [PATCH] mm/gup.c: Handling ERR within unpin_user_pages() Souptick Joarder
2020-09-13 14:55 ` Matthew Wilcox
2020-09-14  1:50   ` Souptick Joarder
2020-09-14 14:08     ` Jason Gunthorpe
2020-09-14 20:52       ` Souptick Joarder
2020-09-14 20:56         ` John Hubbard
2020-09-14 21:01         ` Ira Weiny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox