diff options
Diffstat (limited to 'src/flash/flash.c')
-rw-r--r-- | src/flash/flash.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/flash/flash.c b/src/flash/flash.c index 3478b6a2..3b2abe23 100644 --- a/src/flash/flash.c +++ b/src/flash/flash.c @@ -829,12 +829,15 @@ int handle_flash_write_bank_command(struct command_context_s *cmd_ctx, char *cmd buffer = malloc(fileio.size); if (fileio_read(&fileio, fileio.size, buffer, &buf_cnt) != ERROR_OK) { + free(buffer); + fileio_close(&fileio); return ERROR_OK; } retval = flash_driver_write(p, buffer, offset, buf_cnt); free(buffer); + buffer = NULL; duration_stop_measure(&duration, &duration_text); if (retval!=ERROR_OK) |