summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorFerdinand Blomqvist <ferdinand.blomqvist@gmail.com>2019-06-20 17:10:34 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-07-26 09:10:37 +0200
commit503b1de9c15fe28f7edbcec80a67fe9279bcfa13 (patch)
tree5ca6ad39d12754ee0140796f94eebe156eb244b8 /lib
parentb02beb2e50ed7ad5c21b7c66dbaf10d846285309 (diff)
downloadlinux-stable-503b1de9c15fe28f7edbcec80a67fe9279bcfa13.tar.gz
linux-stable-503b1de9c15fe28f7edbcec80a67fe9279bcfa13.tar.bz2
linux-stable-503b1de9c15fe28f7edbcec80a67fe9279bcfa13.zip
rslib: Fix decoding of shortened codes
[ Upstream commit 2034a42d1747fc1e1eeef2c6f1789c4d0762cb9c ] 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: Ferdinand Blomqvist <ferdinand.blomqvist@gmail.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lkml.kernel.org/r/20190620141039.9874-3-ferdinand.blomqvist@gmail.com Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/reed_solomon/decode_rs.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/reed_solomon/decode_rs.c b/lib/reed_solomon/decode_rs.c
index 1db74eb098d0..3313bf944ff1 100644
--- a/lib/reed_solomon/decode_rs.c
+++ b/lib/reed_solomon/decode_rs.c
@@ -99,9 +99,9 @@
if (no_eras > 0) {
/* Init lambda to be the erasure locator polynomial */
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++) {
- 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--) {
tmp = index_of[lambda[j - 1]];
if (tmp != nn) {