1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 05:12:57 +01:00

drivers/mtd_flashpage: require the write source buffer to be aligned

This commit is contained in:
Benjamin Valentin 2021-02-22 10:24:39 +01:00
parent 2bdc5cf6d7
commit 0b79ae3524

View File

@ -24,6 +24,7 @@
#include <assert.h>
#include "architecture.h"
#include "cpu.h"
#include "cpu_conf.h"
#include "mtd_flashpage.h"
#include "periph/flashpage.h"
@ -53,6 +54,11 @@ static int _write(mtd_dev_t *dev, const void *buf, uint32_t addr, uint32_t size)
{
(void)dev;
#ifndef CPU_HAS_UNALIGNED_ACCESS
if ((uintptr_t)buf % sizeof(uword_t)) {
return -EINVAL;
}
#endif
if (addr % FLASHPAGE_WRITE_BLOCK_ALIGNMENT) {
return -EINVAL;
}