[PATCH] powerpc: Avoid panic during boot due to divide by zero in init_cache_info()

Michael Ellerman mpe at ellerman.id.au
Sun Mar 5 21:26:47 AEDT 2017


Anton Blanchard <anton at ozlabs.org> writes:

> From: Anton Blanchard <anton at samba.org>
>
> 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.

Erk sorry. One of the static checkers spotted it, but I hadn't got
around to fixing it because it seemed to not actually blow up, guess
not.

cheers


More information about the Linuxppc-dev mailing list