Skip to content

Commit

Permalink
rslib: Fix handling of of caller provided syndrome
Browse files Browse the repository at this point in the history
[ Upstream commit ef4d6a8 ]

Check if the syndrome provided by the caller is zero, and act
accordingly.

Signed-off-by: Ferdinand Blomqvist <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
fblomqvi authored and gregkh committed Jul 31, 2019
1 parent a5a0c29 commit 9a3d442
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/reed_solomon/decode_rs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down

0 comments on commit 9a3d442

Please sign in to comment.