diff options
author | Jan Kara <jack@suse.cz> | 2017-11-03 14:21:21 +0300 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2017-11-03 16:25:51 +0300 |
commit | 592e254502041f953e84d091eae2c68cba04c10b (patch) | |
tree | 536241d5f7df82fbf45bb37a464fb0e93939df2b /include/linux | |
parent | 8a5776a5f49812d29fe4b2d0a2d71675c3facf3f (diff) | |
download | linux-592e254502041f953e84d091eae2c68cba04c10b.tar.xz |
mm: Handle 0 flags in _calc_vm_trans() macro
_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>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/mman.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/include/linux/mman.h b/include/linux/mman.h index c8367041fafd..edb6cf6a81ed 100644 --- a/include/linux/mman.h +++ b/include/linux/mman.h @@ -63,8 +63,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. |