mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-07 18:05:21 +02:00
powerpc/boot: Handle allocation failure in simple_realloc()
[ Upstream commit 69b0194cce
]
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>
This commit is contained in:
parent
881613a975
commit
9c96b5b056
|
@ -112,7 +112,9 @@ static void *simple_realloc(void *ptr, unsigned long size)
|
||||||
return ptr;
|
return ptr;
|
||||||
|
|
||||||
new = simple_malloc(size);
|
new = simple_malloc(size);
|
||||||
|
if (new)
|
||||||
memcpy(new, ptr, p->size);
|
memcpy(new, ptr, p->size);
|
||||||
|
|
||||||
simple_free(ptr);
|
simple_free(ptr);
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user