Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cd146e31 authored by Li zeming's avatar Li zeming Committed by Greg Kroah-Hartman
Browse files

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: default avatarLi zeming <zeming@nfschina.com>
[mpe: Reword subject, use change log from Christophe]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20221219021816.3012-1-zeming@nfschina.com


Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent fea29d47
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -114,7 +114,9 @@ static void *simple_realloc(void *ptr, unsigned long size)
		return ptr;

	new = simple_malloc(size);
	if (new)
		memcpy(new, ptr, p->size);

	simple_free(ptr);
	return new;
}