summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2017-11-03 12:21:21 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-12-20 10:10:26 +0100
commitf58a90e027d8ff3f24e20429500f0923663afbd4 (patch)
tree43da41192c6e5ccbd22a00b59a39edc2b03066e1 /include
parent6479a108b35857674ca2a74e049e3089d12ee444 (diff)
downloadlinux-stable-f58a90e027d8ff3f24e20429500f0923663afbd4.tar.gz
linux-stable-f58a90e027d8ff3f24e20429500f0923663afbd4.tar.bz2
linux-stable-f58a90e027d8ff3f24e20429500f0923663afbd4.zip
mm: Handle 0 flags in _calc_vm_trans() macro
[ Upstream commit 592e254502041f953e84d091eae2c68cba04c10b ] _calc_vm_trans() does not handle the situation when some of the passed flags are 0 (which can happen if these VM flags do not make sense for the architecture). Improve the _calc_vm_trans() macro to return 0 in such situation. Since all passed flags are constant, this does not add any runtime overhead. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/mman.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/linux/mman.h b/include/linux/mman.h
index 7c87b6652244..835a6f2fd8d4 100644
--- a/include/linux/mman.h
+++ b/include/linux/mman.h
@@ -64,8 +64,9 @@ static inline bool arch_validate_prot(unsigned long prot)
* ("bit1" and "bit2" must be single bits)
*/
#define _calc_vm_trans(x, bit1, bit2) \
+ ((!(bit1) || !(bit2)) ? 0 : \
((bit1) <= (bit2) ? ((x) & (bit1)) * ((bit2) / (bit1)) \
- : ((x) & (bit1)) / ((bit1) / (bit2)))
+ : ((x) & (bit1)) / ((bit1) / (bit2))))
/*
* Combine the mmap "prot" argument into "vm_flags" used internally.