powerpc/boot: Handle allocation failure in simple_realloc()
BugLink: https://bugs.launchpad.net/bugs/2084005 [ 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> Signed-off-by: Koichiro Den <koichiro.den@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
This commit is contained in:
committed by
Mehmet Basaran
parent
d857993e33
commit
74217746a3
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user