summaryrefslogtreecommitdiffstats
path: root/lib/reed_solomon
diff options
context:
space:
mode:
authorFerdinand Blomqvist <ferdinand.blomqvist@gmail.com>2019-06-20 17:10:37 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-07-31 07:28:30 +0200
commit9a3d442c240fa33d9c16a36588016536be8a3228 (patch)
tree3da12eca3782a120313fd66a6c48b8a8a10c3015 /lib/reed_solomon
parenta5a0c29fa41bc1c67c8f5d3c612d697b52ad1362 (diff)
downloadlinux-stable-9a3d442c240fa33d9c16a36588016536be8a3228.tar.gz
linux-stable-9a3d442c240fa33d9c16a36588016536be8a3228.tar.bz2
linux-stable-9a3d442c240fa33d9c16a36588016536be8a3228.zip
rslib: Fix handling of of caller provided syndrome
[ Upstream commit ef4d6a8556b637ad27c8c2a2cff1dda3da38e9a9 ] Check if the syndrome provided by the caller is zero, and act accordingly. 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-6-ferdinand.blomqvist@gmail.com Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'lib/reed_solomon')
-rw-r--r--lib/reed_solomon/decode_rs.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/reed_solomon/decode_rs.c b/lib/reed_solomon/decode_rs.c
index 8eed0f9ac495..a5d313381539 100644
--- a/lib/reed_solomon/decode_rs.c
+++ b/lib/reed_solomon/decode_rs.c
@@ -42,8 +42,18 @@
BUG_ON(pad < 0 || pad >= nn);
/* Does the caller provide the syndrome ? */
- if (s != NULL)
- goto decode;
+ if (s != NULL) {
+ for (i = 0; i < nroots; i++) {
+ /* The syndrome is in index form,
+ * so nn represents zero
+ */
+ if (s[i] != nn)
+ goto decode;
+ }
+
+ /* syndrome is zero, no errors to correct */
+ return 0;
+ }
/* form the syndromes; i.e., evaluate data(x) at roots of
* g(x) */