From f622bcfe4fd966af4c5ac5deadb4f3e74026078b Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Mon, 28 Mar 2022 21:27:41 +0100 Subject: [PATCH] buflib: fix buflib_context_relocate alignment check Use the standard IS_ALIGNED macro and check alignment against sizeof(buflib_data), as it can be greater than 4 bytes if we're on a 64-bit platform (eg. simulator). Change-Id: I15110937d1f2978e733d169050de9531fe218214 --- firmware/buflib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/buflib.c b/firmware/buflib.c index 4551fd8dca..05e489ea14 100644 --- a/firmware/buflib.c +++ b/firmware/buflib.c @@ -144,7 +144,7 @@ bool buflib_context_relocate(struct buflib_context *ctx, void *buf) /* cannot continue if the buffer is not aligned, since we would need * to reduce the size of the buffer for aligning */ - if ((uintptr_t)buf & 0x3) + if (!IS_ALIGNED((uintptr_t)buf, sizeof(union buflib_data))) return false; /* relocate the handle table entries */