diff --git a/src/panfrost/lib/decode.c b/src/panfrost/lib/decode.c index 07366e45072..7a67121a91b 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); }