[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Mon, 19 Dec 2022 10:18:16 +0800
From: Li zeming <zeming@...china.com>
To: mpe@...erman.id.au, npiggin@...il.com, christophe.leroy@...roup.eu,
gregkh@...uxfoundation.org
Cc: linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org,
Li zeming <zeming@...china.com>
Subject: [PATCH] boot: simple_alloc: check after increasing memory allocation
The pointer new adds judgment and should help with program robustness.
Signed-off-by: Li zeming <zeming@...china.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
Powered by blists - more mailing lists