]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
rslib: Fix handling of of caller provided syndrome
authorFerdinand Blomqvist <ferdinand.blomqvist@gmail.com>
Thu, 20 Jun 2019 14:10:37 +0000 (17:10 +0300)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1839036
[ 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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
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) */