summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-06-21 16:38:44 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2024-07-18 18:33:30 -0400
commit73f88592dd1bef38542024ef8223599afc2c41bb (patch)
tree78ab50c2c9398eb8e173401c427aebdf3201d01a /fs
parenta97b43fac5b9b3ffca71b8a917a249789902fce9 (diff)
downloadlwn-73f88592dd1bef38542024ef8223599afc2c41bb.tar.gz
lwn-73f88592dd1bef38542024ef8223599afc2c41bb.zip
bcachefs: mean_and_variance: Avoid too-large shift amounts
Shifting a value by the width of its type or more is undefined. Signed-off-by: Tavian Barnes <tavianator@tavianator.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r--fs/bcachefs/mean_and_variance.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/bcachefs/mean_and_variance.h b/fs/bcachefs/mean_and_variance.h
index 4fcf062dd22c..47e4a3c3d26e 100644
--- a/fs/bcachefs/mean_and_variance.h
+++ b/fs/bcachefs/mean_and_variance.h
@@ -111,11 +111,11 @@ static inline u128_u u128_shl(u128_u i, s8 shift)
{
u128_u r;
- r.lo = i.lo << shift;
+ r.lo = i.lo << (shift & 63);
if (shift < 64)
- r.hi = (i.hi << shift) | (i.lo >> (64 - shift));
+ r.hi = (i.hi << (shift & 63)) | (i.lo >> (-shift & 63));
else {
- r.hi = i.lo << (shift - 64);
+ r.hi = i.lo << (-shift & 63);
r.lo = 0;
}
return r;