projects
/
platform
/
upstream
/
mesa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6642749
)
pan/decode: Avoid undefined behaviour on shift in bits()
author
Icecream95
<ixn@disroot.org>
Wed, 14 Jul 2021 00:47:30 +0000
(12:47 +1200)
committer
Marge Bot
<eric+marge@anholt.net>
Wed, 14 Jul 2021 23:20:13 +0000
(23:20 +0000)
v2: Return 0 instead of `word` (Alyssa)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11869>
src/panfrost/lib/decode.c
patch
|
blob
|
history
diff --git
a/src/panfrost/lib/decode.c
b/src/panfrost/lib/decode.c
index
07366e4
..
7a67121
100644
(file)
--- 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);
}