[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1600007555-11650-1-git-send-email-jrdr.linux@gmail.com>
Date: Sun, 13 Sep 2020 20:02:35 +0530
From: Souptick Joarder <jrdr.linux@...il.com>
To: akpm@...ux-foundation.org
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Souptick Joarder <jrdr.linux@...il.com>,
John Hubbard <jhubbard@...dia.com>
Subject: [PATCH] mm/gup.c: Handling ERR within unpin_user_pages()
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@...il.com>
Cc: John Hubbard <jhubbard@...dia.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
Powered by blists - more mailing lists