Commit ef4d6a85 authored by Ferdinand Blomqvist's avatar Ferdinand Blomqvist Committed by Thomas Gleixner
Browse files

rslib: Fix handling of of caller provided syndrome



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

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-6-ferdinand.blomqvist@gmail.com
parent 647cc9ec
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -42,8 +42,18 @@
	BUG_ON(pad < 0 || pad >= nn - nroots);

	/* Does the caller provide the syndrome ? */
	if (s != NULL)
	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) */