]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - lib/reed_solomon/decode_rs.c
rslib: Fix handling of of caller provided syndrome
[mirror_ubuntu-bionic-kernel.git] / lib / reed_solomon / decode_rs.c
index 8eed0f9ac49503c72b39b79b257d5309a18b075a..a5d313381539dd11f6d69ba914f8decedf6ca37a 100644 (file)
        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) */