summaryrefslogtreecommitdiffstats
path: root/arch/powerpc/boot
diff options
context:
space:
mode:
authorLi zeming <zeming@nfschina.com>2022-12-19 10:18:16 +0800
committerMichael Ellerman <mpe@ellerman.id.au>2024-03-03 22:20:28 +1100
commit69b0194ccec033c208b071e019032c1919c2822d (patch)
tree14fba095c0f54995f1506b338b4568bf532402aa /arch/powerpc/boot
parentcda9c0d556283e2d4adaa9960b2dc19b16156bae (diff)
downloadlinux-stable-69b0194ccec033c208b071e019032c1919c2822d.tar.gz
linux-stable-69b0194ccec033c208b071e019032c1919c2822d.tar.bz2
linux-stable-69b0194ccec033c208b071e019032c1919c2822d.zip
powerpc/boot: Handle allocation failure in simple_realloc()
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
Diffstat (limited to 'arch/powerpc/boot')
-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 267d6524caac..db9aaa5face3 100644
--- a/arch/powerpc/boot/simple_alloc.c
+++ b/arch/powerpc/boot/simple_alloc.c
@@ -112,7 +112,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;
}