LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] boot: simple_alloc: check after increasing memory allocation
@ 2022-12-19  2:18 Li zeming
  2022-12-19  6:42 ` Christophe Leroy
  2024-03-13 13:19 ` Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Li zeming @ 2022-12-19  2:18 UTC (permalink / raw)
  To: mpe, npiggin, christophe.leroy, gregkh
  Cc: linuxppc-dev, linux-kernel, Li zeming

The pointer new adds judgment and should help with program robustness.

Signed-off-by: Li zeming <zeming@nfschina.com>
---
 arch/powerpc/boot/simple_alloc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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;
 }
-- 
2.18.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-13 13:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-19  2:18 [PATCH] boot: simple_alloc: check after increasing memory allocation Li zeming
2022-12-19  6:42 ` Christophe Leroy
2024-03-13 13:19 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox