From: Ferdinand Blomqvist Date: Thu, 20 Jun 2019 14:10:37 +0000 (+0300) Subject: rslib: Fix handling of of caller provided syndrome X-Git-Tag: Ubuntu-4.15.0-61.68~710 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=f213af1c317a73008a844f6173a414b180bf202b;hp=2894ecafb808d05ad9b1f21ab3d84780930e040c;p=mirror_ubuntu-bionic-kernel.git rslib: Fix handling of of caller provided syndrome 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 Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/20190620141039.9874-6-ferdinand.blomqvist@gmail.com Signed-off-by: Sasha Levin Signed-off-by: Kamal Mostafa Signed-off-by: Khalid Elmously --- diff --git a/lib/reed_solomon/decode_rs.c b/lib/reed_solomon/decode_rs.c index 8eed0f9ac495..a5d313381539 100644 --- a/lib/reed_solomon/decode_rs.c +++ b/lib/reed_solomon/decode_rs.c @@ -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) */