linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Krause <xerofoify@gmail.com>
To: akpm@linux-foundation.org
Cc: mhocko@suse.cz, riel@redhat.com, kirill.shutemov@linux.intel.com,
	hannes@cmpxchg.org, dave@stgolabs.net, koct9i@gmail.com,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH] mm: Add error check after call to rmap_walk in the function page_referenced
Date: Thu, 25 Jun 2015 21:36:37 -0400	[thread overview]
Message-ID: <1435282597-21728-1-git-send-email-xerofoify@gmail.com> (raw)

This adds a return check after the call to the function rmap_walk
in the function page_referenced as this function call can fail
and thus should signal callers of page_referenced if this happens
by returning the SWAP macro return value as returned by rmap_walk
here. In addition also check if have locked the page pointer as
passed to this particular and unlock it with unlock_page if this
page is locked before returning our SWAP marco return code from
rmap_walk.

Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
---
 mm/rmap.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/mm/rmap.c b/mm/rmap.c
index 171b687..e4df848 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -814,7 +814,9 @@ static bool invalid_page_referenced_vma(struct vm_area_struct *vma, void *arg)
  * @vm_flags: collect encountered vma->vm_flags who actually referenced the page
  *
  * Quick test_and_clear_referenced for all mappings to a page,
- * returns the number of ptes which referenced the page.
+ * returns the number of ptes which referenced the page.On
+ * error returns either zero or the error code returned from
+ * the failed call to rmap_walk.
  */
 int page_referenced(struct page *page,
 		    int is_locked,
@@ -855,7 +857,13 @@ int page_referenced(struct page *page,
 		rwc.invalid_vma = invalid_page_referenced_vma;
 	}
 
+
 	ret = rmap_walk(page, &rwc);
+	if (!ret) {
+		if (we_locked)
+			unlock_page(page);
+		return ret;
+	}
 	*vm_flags = pra.vm_flags;
 
 	if (we_locked)
-- 
2.1.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2015-06-26  1:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-26  1:36 Nicholas Krause [this message]
2015-06-26 13:56 ` Dominik Dingel
2015-06-26 14:47   ` nick
2015-06-26 15:18     ` Dominik Dingel
2015-06-26 15:40       ` nick

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1435282597-21728-1-git-send-email-xerofoify@gmail.com \
    --to=xerofoify@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave@stgolabs.net \
    --cc=hannes@cmpxchg.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=koct9i@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.cz \
    --cc=riel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox