[CRIU] [PATCH] rst-malloc: return aligned pointers to sizeof(void *) (v2)

Andrey Vagin avagin at openvz.org
Fri Jan 22 10:32:24 PST 2016


From: Andrew Vagin <avagin at virtuozzo.com>

Stas found that if we don't align a pointer,
futex and atomic operations can fail.

v2: don't hard-code the size of void *

Cc: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 rst-malloc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/rst-malloc.c b/rst-malloc.c
index 14e0b41..153f0ce 100644
--- a/rst-malloc.c
+++ b/rst-malloc.c
@@ -145,6 +145,8 @@ void *rst_mem_alloc(unsigned long size, int type)
 
 	BUG_ON(!t->enabled);
 
+	size = round_up(size, sizeof(void *));
+
 	if ((t->free_bytes < size) && t->grow(t, size)) {
 		pr_perror("Can't grow rst mem");
 		return NULL;
-- 
2.4.3



More information about the CRIU mailing list