From 08e6e2d2dd507a07fe37dfc339a4371d47ab4cfe Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Thu, 3 Feb 2022 11:25:40 +0100 Subject: [PATCH] Return when a write fails Signed-off-by: Pol Henarejos --- flash.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/flash.c b/flash.c index 65eef1a..0c1ab13 100644 --- a/flash.c +++ b/flash.c @@ -281,9 +281,12 @@ flash_data_pool_allocate (size_t size) size = (size + 1) & ~1; /* allocation unit is 1-halfword (2-byte) */ - if (is_data_pool_full (size)) - if (flash_copying_gc () < 0 || /*still*/ is_data_pool_full (size)) + if (is_data_pool_full (size)) { + if (flash_copying_gc () < 0 || /*still*/ is_data_pool_full (size)) { TU_LOG1 ("!!!! FATAL: %d\r\n",FATAL_FLASH); + return NULL; + } + } p = last_p; last_p += size; @@ -519,6 +522,7 @@ flash_put_data (uint16_t hw) if (p == NULL) { DEBUG_INFO ("data allocation failure.\r\n"); + return; } flash_program_halfword ((uintptr_t)p, hw);