summaryrefslogtreecommitdiff
path: root/arch/powerpc
diff options
context:
space:
mode:
authorLi zeming <zeming@nfschina.com>2022-12-19 05:18:16 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-09-04 14:23:25 +0300
commitde34590df6a300b7fdf7886f18e486567bf7c38a (patch)
treefba07c9391498236a5bc05e630181fe72b02faf0 /arch/powerpc
parent4a8de7a7fc2bbf141dc36c5506988da135b4828b (diff)
downloadlinux-de34590df6a300b7fdf7886f18e486567bf7c38a.tar.xz
powerpc/boot: Handle allocation failure in simple_realloc()
[ Upstream commit 69b0194ccec033c208b071e019032c1919c2822d ] simple_malloc() will return NULL when there is not enough memory left. Check pointer 'new' before using it to copy the old data. Signed-off-by: Li zeming <zeming@nfschina.com> [mpe: Reword subject, use change log from Christophe] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20221219021816.3012-1-zeming@nfschina.com Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/boot/simple_alloc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/powerpc/boot/simple_alloc.c b/arch/powerpc/boot/simple_alloc.c
index 65ec135d0157..188c4f996512 100644
--- a/arch/powerpc/boot/simple_alloc.c
+++ b/arch/powerpc/boot/simple_alloc.c
@@ -114,7 +114,9 @@ static void *simple_realloc(void *ptr, unsigned long size)
return ptr;
new = simple_malloc(size);
- memcpy(new, ptr, p->size);
+ if (new)
+ memcpy(new, ptr, p->size);
+
simple_free(ptr);
return new;
}