diff options
| author | Josh Law <objecting@objecting.org> | 2026-03-18 07:48:06 +0000 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-03-27 21:19:48 -0700 |
| commit | 010d7d9846504f97da649595c61985137ca67cd4 (patch) | |
| tree | 712e5272d9a2a6514020958f392fd16feac2d801 | |
| parent | f42b510990030bbc0d6e4ba4486decbcd952b924 (diff) | |
lib/bch: fix signed shift overflow in build_mod8_tables
Cast loop variable to unsigned int before left-shifting to avoid undefined
behavior when i >= 128 and b == 3 (i << 24 overflows signed int).
Link: https://lkml.kernel.org/r/20260318074806.16527-3-objecting@objecting.org
Signed-off-by: Josh Law <objecting@objecting.org>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Ivan Djelic <ivan.djelic@parrot.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
| -rw-r--r-- | lib/bch.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/bch.c b/lib/bch.c index ef733f08082f..c991c71c4cbd 100644 --- a/lib/bch.c +++ b/lib/bch.c @@ -1116,7 +1116,7 @@ static void build_mod8_tables(struct bch_control *bch, const uint32_t *g) for (b = 0; b < 4; b++) { /* we want to compute (p(X).X^(8*b+deg(g))) mod g(X) */ tab = bch->mod8_tab + (b*256+i)*l; - data = i << (8*b); + data = (unsigned int)i << (8*b); while (data) { d = deg(data); /* subtract X^d.g(X) from p(X).X^(8*b+deg(g)) */ |
