1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-15 01:23:49 +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,9 +76,11 @@ int mtd_init(mtd_dev_t *mtd)
#ifdef MODULE_MTD_WRITE_PAGE
if ((mtd->driver->flags & MTD_DRIVER_FLAG_DIRECT_WRITE) == 0) {
mtd->work_area = malloc(mtd->pages_per_sector * mtd->page_size);
if (mtd->work_area == NULL) {
res = -ENOMEM;
if (!mtd->work_area) {
mtd->work_area = malloc(mtd->pages_per_sector * mtd->page_size);
if (mtd->work_area == NULL) {
res = -ENOMEM;
}
}
}
#endif