mm: madvise(): correct return code
commit75927af8bcb940dad4fe281713d526cb520869ff
authorNick Piggin <npiggin@suse.de>
Tue, 16 Jun 2009 22:32:38 +0000 (16 15:32 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 17 Jun 2009 02:47:40 +0000 (16 19:47 -0700)
tree96b2b903ce215d3c47204b7b77724c9fa0aa6502
parentdab48dab37d2770824420d1e01730a107fade1aa
mm: madvise(): correct return code

The posix_madvise() function succeeds (and does nothing) when called with
parameters (NULL, 0, -1); according to LSB tests, it should fail with
EINVAL because -1 is not a valid flag.

When called with a valid address and size, it correctly fails.

So perform an initial check for valid flags first.

Reported-by: Jiri Dluhos <jdluhos@novell.com>
Signed-off-by: Nick Piggin <npiggin@suse.de>
Reviewed-and-Tested-by: WANG Cong <xiyou.wangcong@gmail.com>
Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/madvise.c