projects
/
linux-2.6-microblaze.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
69b0194
)
powerpc/boot: Only free if realloc() succeeds
author
Michael Ellerman
<mpe@ellerman.id.au>
Thu, 29 Feb 2024 11:51:49 +0000
(22:51 +1100)
committer
Michael Ellerman
<mpe@ellerman.id.au>
Sun, 3 Mar 2024 11:20:29 +0000
(22:20 +1100)
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
arch/powerpc/boot/simple_alloc.c
patch
|
blob
|
history
diff --git
a/arch/powerpc/boot/simple_alloc.c
b/arch/powerpc/boot/simple_alloc.c
index
db9aaa5
..
d07796f
100644
(file)
--- a/
arch/powerpc/boot/simple_alloc.c
+++ b/
arch/powerpc/boot/simple_alloc.c
@@
-112,10
+112,11
@@
static void *simple_realloc(void *ptr, unsigned long size)
return ptr;
new = simple_malloc(size);
- if (new)
+ if (new)
{
memcpy(new, ptr, p->size);
+ simple_free(ptr);
+ }
- simple_free(ptr);
return new;
}