1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-18 19:13:51 +01:00

drivers/mtd: prevent work_area double allocation

This commit is contained in:
Fabian Hüßler 2025-02-12 16:25:59 +01:00
parent 452f75fa3c
commit 9e7a269de0

View File

@ -76,11 +76,13 @@ int mtd_init(mtd_dev_t *mtd)
#ifdef MODULE_MTD_WRITE_PAGE #ifdef MODULE_MTD_WRITE_PAGE
if ((mtd->driver->flags & MTD_DRIVER_FLAG_DIRECT_WRITE) == 0) { if ((mtd->driver->flags & MTD_DRIVER_FLAG_DIRECT_WRITE) == 0) {
if (!mtd->work_area) {
mtd->work_area = malloc(mtd->pages_per_sector * mtd->page_size); mtd->work_area = malloc(mtd->pages_per_sector * mtd->page_size);
if (mtd->work_area == NULL) { if (mtd->work_area == NULL) {
res = -ENOMEM; res = -ENOMEM;
} }
} }
}
#endif #endif
return res; return res;