bitops: avoid integer overflow in GENMASK(_ULL)
authorMatthias Kaehlcke <mka@chromium.org>
Fri, 8 Sep 2017 23:14:33 +0000 (16:14 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 May 2019 17:19:33 +0000 (19:19 +0200)
commitc6693781ddaf21dd3746bd74ba0c66e013782b06
treeec44afbd15efe1708df1e0299a7dc484300150af
parent08e501b5ff9f67f592b33d5e76e28d539a490041
bitops: avoid integer overflow in GENMASK(_ULL)

commit c32ee3d9abd284b4fcaacc250b101f93829c7bae upstream.

GENMASK(_ULL) performs a left-shift of ~0UL(L), which technically
results in an integer overflow.  clang raises a warning if the overflow
occurs in a preprocessor expression.  Clear the low-order bits through a
substraction instead of the left-shift to avoid the overflow.

(akpm: no change in .text size in my testing)

Link: http://lkml.kernel.org/r/20170803212020.24939-1-mka@chromium.org
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/bitops.h