Commit 73b71649 authored by Ferdinand Blomqvist's avatar Ferdinand Blomqvist Committed by Stefan Bader

rslib: Fix decoding of shortened codes

BugLink: https://bugs.launchpad.net/bugs/1840081

[ Upstream commit 2034a42d ]

The decoding of shortenend codes is broken. It only works as expected if
there are no erasures.

When decoding with erasures, Lambda (the error and erasure locator
polynomial) is initialized from the given erasure positions. The pad
parameter is not accounted for by the initialisation code, and hence
Lambda is initialized from incorrect erasure positions.

The fix is to adjust the erasure positions by the supplied pad.
Signed-off-by: default avatarFerdinand Blomqvist <ferdinand.blomqvist@gmail.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20190620141039.9874-3-ferdinand.blomqvist@gmail.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 386d00ad
...@@ -99,9 +99,9 @@ ...@@ -99,9 +99,9 @@
if (no_eras > 0) { if (no_eras > 0) {
/* Init lambda to be the erasure locator polynomial */ /* Init lambda to be the erasure locator polynomial */
lambda[1] = alpha_to[rs_modnn(rs, lambda[1] = alpha_to[rs_modnn(rs,
prim * (nn - 1 - eras_pos[0]))]; prim * (nn - 1 - (eras_pos[0] + pad)))];
for (i = 1; i < no_eras; i++) { for (i = 1; i < no_eras; i++) {
u = rs_modnn(rs, prim * (nn - 1 - eras_pos[i])); u = rs_modnn(rs, prim * (nn - 1 - (eras_pos[i] + pad)));
for (j = i + 1; j > 0; j--) { for (j = i + 1; j > 0; j--) {
tmp = index_of[lambda[j - 1]]; tmp = index_of[lambda[j - 1]];
if (tmp != nn) { if (tmp != nn) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment