rslib: Fix handling of of caller provided syndrome

[ Upstream commit ef4d6a8556 ]

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>
This commit is contained in:
Ferdinand Blomqvist 2019-06-20 17:10:37 +03:00 коммит произвёл Greg Kroah-Hartman
Родитель a5a0c29fa4
Коммит 9a3d442c24
1 изменённых файлов: 12 добавлений и 2 удалений

Просмотреть файл

@ -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) */