[lttng-dev] [PATCH v2] Fix: Align buffers from objstack_alloc on sizeof(void *)
rongqing.li at windriver.com
rongqing.li at windriver.com
Thu May 15 22:10:38 EDT 2014
From: Fredrik Markström <fredrik.markstrom at gmail.com>
The buffers from objstack_alloc will store the pointer, so it must
be aligned on pointer, or else it will cause issue on the cpu
which does not support unaligned addresses access
Signed-off-by: Fredrik Markstrom <fredrik.markstrom at gmail.com>
Signed-off-by: Roy Li <rongqing.li at windriver.com>
---
formats/ctf/metadata/objstack.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/formats/ctf/metadata/objstack.c b/formats/ctf/metadata/objstack.c
index 9e264a4..0e7d04e 100644
--- a/formats/ctf/metadata/objstack.c
+++ b/formats/ctf/metadata/objstack.c
@@ -39,7 +39,7 @@ struct objstack_node {
struct bt_list_head node;
size_t len;
size_t used_len;
- char data[];
+ char __attribute__ ((aligned (sizeof(void *)))) data[];
};
BT_HIDDEN
@@ -118,6 +118,8 @@ void *objstack_alloc(struct objstack *objstack, size_t len)
struct objstack_node *last_node;
void *p;
+ len = ALIGN(len, sizeof(void *));
+
/* Get last node */
last_node = bt_list_entry(objstack->head.prev,
struct objstack_node, node);
--
1.7.10.4
More information about the lttng-dev
mailing list