Commit b59614cf authored by Jan Kara's avatar Jan Kara Committed by Greg Kroah-Hartman

mm: Handle 0 flags in _calc_vm_trans() macro


[ Upstream commit 592e2545 ]

_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: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 44de70ec
...@@ -63,8 +63,9 @@ static inline int arch_validate_prot(unsigned long prot) ...@@ -63,8 +63,9 @@ static inline int arch_validate_prot(unsigned long prot)
* ("bit1" and "bit2" must be single bits) * ("bit1" and "bit2" must be single bits)
*/ */
#define _calc_vm_trans(x, bit1, bit2) \ #define _calc_vm_trans(x, bit1, bit2) \
((!(bit1) || !(bit2)) ? 0 : \
((bit1) <= (bit2) ? ((x) & (bit1)) * ((bit2) / (bit1)) \ ((bit1) <= (bit2) ? ((x) & (bit1)) * ((bit2) / (bit1)) \
: ((x) & (bit1)) / ((bit1) / (bit2))) : ((x) & (bit1)) / ((bit1) / (bit2))))
/* /*
* Combine the mmap "prot" argument into "vm_flags" used internally. * Combine the mmap "prot" argument into "vm_flags" used internally.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment