From: Icecream95 Date: Wed, 14 Jul 2021 00:47:30 +0000 (+1200) Subject: pan/decode: Avoid undefined behaviour on shift in bits() X-Git-Tag: upstream/22.3.5~20200 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=04c02418d74703812a39405df14e130c2d6fd098;p=platform%2Fupstream%2Fmesa.git pan/decode: Avoid undefined behaviour on shift in bits() v2: Return 0 instead of `word` (Alyssa) Part-of: --- diff --git a/src/panfrost/lib/decode.c b/src/panfrost/lib/decode.c index 07366e4..7a67121 100644 --- a/src/panfrost/lib/decode.c +++ b/src/panfrost/lib/decode.c @@ -451,6 +451,9 @@ bits(u32 word, u32 lo, u32 hi) if (hi - lo >= 32) return word; // avoid undefined behavior with the shift + if (lo >= 32) + return 0; + return (word >> lo) & ((1 << (hi - lo)) - 1); }