Skip to content

Commit 8f5420f

Browse files
andrzej-kaczmarekAnas Nashif
authored andcommitted
drivers: flash: Fix write_op unaligned access
data_addr is not guaranteed to be word-aligned so we need to read it in a safe way, otherwise this can trigger hardfault on nRF51. Signed-off-by: Andrzej Kaczmarek <[email protected]>
1 parent 3625d7c commit 8f5420f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/flash/soc_flash_nrf5.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,8 @@ static int write_op(void *context)
468468
/* Write all the 4-byte aligned data */
469469
while (w_ctx->len >= sizeof(u32_t)) {
470470
nvmc_wait_ready();
471-
*(u32_t *)w_ctx->flash_addr = *(u32_t *)w_ctx->data_addr;
471+
*(u32_t *)w_ctx->flash_addr =
472+
UNALIGNED_GET((u32_t *)w_ctx->data_addr);
472473

473474
shift_write_context(sizeof(u32_t), w_ctx);
474475

0 commit comments

Comments
 (0)