]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/crash: Rearrange loop condition to avoid out of bounds array access
authorSuraj Jitindar Singh <sjitindarsingh@gmail.com>
Mon, 11 Jul 2016 04:17:31 +0000 (14:17 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 14 Jul 2016 10:26:22 +0000 (20:26 +1000)
commit2d4318ec80464d6f418faa65ebf8de432177f01a
tree1d6dba9b22132ce5c15c994855689f9ee8d1c2dd
parent621c488e9cf7a4496166d061a47e373002e25cec
powerpc/crash: Rearrange loop condition to avoid out of bounds array access

The array crash_shutdown_handles[] has size CRASH_HANDLER_MAX, thus when
we loop over the elements of the list we check crash_shutdown_handles[i]
&& i < CRASH_HANDLER_MAX. However this means that when we increment i to
CRASH_HANDLER_MAX we will perform an out of bound array access checking
the first condition before exiting on the second condition.

To avoid the out of bounds access, simply reorder the loop conditions.

Fixes: 23d8f8c66f7e ("powerpc: Add array bounds checking to crash_shutdown_handlers")
Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/crash.c