mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-17 02:36:21 +00:00
powerpc/boot: Only free if realloc() succeeds
simple_realloc() frees the original buffer (ptr) even if the reallocation failed. Fix it to behave like standard realloc() and only free the original buffer if the reallocation succeeded. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20240229115149.749264-1-mpe@ellerman.id.au
This commit is contained in:
parent
69b0194cce
commit
f2d5bccaca
@ -112,10 +112,11 @@ static void *simple_realloc(void *ptr, unsigned long size)
|
|||||||
return ptr;
|
return ptr;
|
||||||
|
|
||||||
new = simple_malloc(size);
|
new = simple_malloc(size);
|
||||||
if (new)
|
if (new) {
|
||||||
memcpy(new, ptr, p->size);
|
memcpy(new, ptr, p->size);
|
||||||
|
simple_free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
simple_free(ptr);
|
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user