powerpc/mm: Fix null-pointer dereference in pgtable_cache_add
authorKunwu Chan <chentao@kylinos.cn>
Mon, 4 Dec 2023 02:32:23 +0000 (10:32 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 5 Feb 2024 20:14:13 +0000 (20:14 +0000)
commit145febd85c3bcc5c74d87ef9a598fc7d9122d532
tree29b69577bc56864a37ddc8499a77150b2452fe6c
parentc918aac94262442a0947017b34d8299a50f5ae1a
powerpc/mm: Fix null-pointer dereference in pgtable_cache_add

[ Upstream commit f46c8a75263f97bda13c739ba1c90aced0d3b071 ]

kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure. Ensure the allocation was successful
by checking the pointer validity.

Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231204023223.2447523-1-chentao@kylinos.cn
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/powerpc/mm/init-common.c