[PATCH] arm: Fix memory alloc/frees for core entry, v2
Cyrill Gorcunov
gorcunov at openvz.org
Thu Jul 4 01:12:28 EDT 2013
- return -1 on error
- assign allocated entries immediately
- test for fpstate allocated on free path
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
CC: Alexander Kartashov <alekskartashov at parallels.com>
---
arch/arm/crtools.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/arch/arm/crtools.c b/arch/arm/crtools.c
index a5acf3b..a7caee3 100644
--- a/arch/arm/crtools.c
+++ b/arch/arm/crtools.c
@@ -160,19 +160,21 @@ int arch_alloc_thread_info(CoreEntry *core)
if (!ti_arm)
goto err;
thread_info_arm__init(ti_arm);
+ core->ti_arm = ti_arm;
gpregs = xmalloc(sizeof(*gpregs));
user_arm_regs_entry__init(gpregs);
ti_arm->gpregs = gpregs;
fpstate = xmalloc(sizeof(*fpstate));
+ if (!fpstate)
+ goto err;
user_arm_vfpstate_entry__init(fpstate);
+ ti_arm->fpstate = fpstate;
fpstate->vfp_regs = xmalloc(32*sizeof(unsigned long long));
fpstate->n_vfp_regs = 32;
- ti_arm->fpstate = fpstate;
-
- core->ti_arm = ti_arm;
-
+ if (!fpstate->vfp_regs)
+ goto err;
thread_core = xmalloc(sizeof(*thread_core));
if (!thread_core)
@@ -180,8 +182,9 @@ int arch_alloc_thread_info(CoreEntry *core)
thread_core_entry__init(thread_core);
core->thread_core = thread_core;
-err:
return 0;
+err:
+ return -1;
}
void arch_free_thread_info(CoreEntry *core)
--
1.8.1.4
--Q68bSM7Ycu6FN28Q--
More information about the CRIU
mailing list