Skip to content

Commit c186bff

Browse files
yolavalkartben
authored andcommitted
drivers: flash: flash_stm32g4x: Fix STM32G4 unaligned read access
Due to source data pointer having no alignment constraint, extra care needs to be taken when reading source data as dword Signed-off-by: Yonas Alizadeh <yonas.alizadeh@alfalaval.com>
1 parent 2a7ffe5 commit c186bff

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/flash/flash_stm32g4x.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ int flash_stm32_write_range(const struct device *dev, unsigned int offset,
246246
int i, rc = 0;
247247

248248
for (i = 0; i < len; i += 8, offset += 8) {
249-
rc = write_dword(dev, offset, ((const uint64_t *) data)[i>>3]);
249+
rc = write_dword(dev, offset, UNALIGNED_GET((const uint64_t *) data + (i>>3)));
250250
if (rc < 0) {
251251
return rc;
252252
}

0 commit comments

Comments
 (0)