]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/legacy_serial: Fix UBSAN: array-index-out-of-bounds
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Sat, 8 May 2021 06:36:21 +0000 (06:36 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 12 May 2021 01:07:39 +0000 (11:07 +1000)
commit525994c5cb31823f19ae5643c22a39b4feaebeb2
tree0a0e52803737495d069d880441beea42a73ade0a
parent9b5b336bfe06a746f156b7eac1d29ae8be7edfa1
powerpc/legacy_serial: Fix UBSAN: array-index-out-of-bounds

UBSAN complains when a pointer is calculated with invalid
'legacy_serial_console' index, allthough the index is verified
before dereferencing the pointer.

Fix it by checking 'legacy_serial_console' validity before
calculating pointers.

Fixes: 77b3cdef21f6 ("powerpc/legacy_serial: Use early_ioremap()")
Reported-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210511010712.750096-1-mpe@ellerman.id.au
arch/powerpc/kernel/legacy_serial.c