]> git.baikalelectronics.ru Git - kernel.git/commit
RAS/CEC: Fix binary search function
authorBorislav Petkov <bp@suse.de>
Sat, 20 Apr 2019 11:27:51 +0000 (13:27 +0200)
committerBorislav Petkov <bp@suse.de>
Fri, 7 Jun 2019 21:18:26 +0000 (23:18 +0200)
commit5ccc0c1323f6a71d84abd633de7348087b20d33f
treef93b40aeee01dc8be879b50cb1a1000133c63681
parent31750888ad4ce9d2a30f744c4c2ab30aee07f569
RAS/CEC: Fix binary search function

Switch to using Donald Knuth's binary search algorithm (The Art of
Computer Programming, vol. 3, section 6.2.1). This should've been done
from the very beginning but the author must've been smoking something
very potent at the time.

The problem with the current one was that it would return the wrong
element index in certain situations:

  https://lkml.kernel.org/r/CAM_iQpVd02zkVJ846cj-Fg1yUNuz6tY5q1Vpj4LrXmE06dPYYg@mail.gmail.com

and the noodling code after the loop was fishy at best.

So switch to using Knuth's binary search. The final result is much
cleaner and straightforward.

Fixes: fa7b27f31422 ("RAS: Add a Corrected Errors Collector")
Reported-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: linux-edac <linux-edac@vger.kernel.org>
Cc: <stable@vger.kernel.org>
drivers/ras/cec.c