linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/madvise: Move up the behavior parameter validation
@ 2017-04-13  9:20 Anshuman Khandual
  2017-04-13 13:59 ` kbuild test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Anshuman Khandual @ 2017-04-13  9:20 UTC (permalink / raw)
  To: linux-kernel, linux-mm; +Cc: n-horiguchi, akpm

The madvise_behavior_valid() function should be called before
acting upon the behavior parameter. Hence move up the function.
This also includes MADV_SOFT_OFFLINE and MADV_HWPOISON options
as valid behavior parameter for the system call madvise().

Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
This applies on top of the other madvise clean up patch I sent
earlier this week https://patchwork.kernel.org/patch/9672095/

 mm/madvise.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/mm/madvise.c b/mm/madvise.c
index efd4721..3cb427a 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -694,6 +694,8 @@ static int madvise_inject_error(int behavior,
 #endif
 	case MADV_DONTDUMP:
 	case MADV_DODUMP:
+	case MADV_SOFT_OFFLINE:
+	case MADV_HWPOISON:
 		return true;
 
 	default:
@@ -767,12 +769,13 @@ static int madvise_inject_error(int behavior,
 	size_t len;
 	struct blk_plug plug;
 
+	if (!madvise_behavior_valid(behavior))
+		return error;
+
 #ifdef CONFIG_MEMORY_FAILURE
 	if (behavior == MADV_HWPOISON || behavior == MADV_SOFT_OFFLINE)
 		return madvise_inject_error(behavior, start, start + len_in);
 #endif
-	if (!madvise_behavior_valid(behavior))
-		return error;
 
 	if (start & ~PAGE_MASK)
 		return error;
-- 
1.8.5.2

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

end of thread, other threads:[~2017-04-19  0:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-13  9:20 [PATCH] mm/madvise: Move up the behavior parameter validation Anshuman Khandual
2017-04-13 13:59 ` kbuild test robot
2017-04-14 13:51 ` [PATCH V2] " Anshuman Khandual
2017-04-17  5:27   ` Naoya Horiguchi
2017-04-18  2:46     ` Anshuman Khandual
2017-04-18  5:28 ` [PATCH V3] " Anshuman Khandual
2017-04-18 21:01   ` David Rientjes
2017-04-19  0:46   ` Naoya Horiguchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).