]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/64: Avoid panic during boot due to divide by zero in init_cache_info()
authorAnton Blanchard <anton@samba.org>
Sat, 4 Mar 2017 23:54:34 +0000 (10:54 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 6 Mar 2017 10:44:09 +0000 (21:44 +1100)
commiteab6cc231c5f2f0e56131614670e2246b29ef670
tree5ab7573657019a678a3607d59a913be3cc86caa3
parentf76a0a025c26d19e9095d17a0f399ec7406bf66b
powerpc/64: Avoid panic during boot due to divide by zero in init_cache_info()

I see a panic in early boot when building with a recent gcc toolchain.
The issue is a divide by zero, which is undefined. Older toolchains
let us get away with it:

int foo(int a) { return a / 0; }

foo:
li 9,0
divw 3,3,9
extsw 3,3
blr

But newer ones catch it:

foo:
trap

Add a check to avoid the divide by zero.

Fixes: e6139eebdfa9 ("powerpc/64: Clean up ppc64_caches using a struct per cache")
Signed-off-by: Anton Blanchard <anton@samba.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/setup_64.c