diff options
author | Spencer Oliver <spen@spen-soft.co.uk> | 2012-08-13 11:22:35 +0100 |
---|---|---|
committer | Freddie Chopin <freddie.chopin@gmail.com> | 2012-08-24 16:49:56 +0000 |
commit | 60a932b36804bff8b6ca40adc665a33a59475db1 (patch) | |
tree | e3a087a3aa6fe883aea25d7f95d5bb05cce68fcd /src/flash | |
parent | fb525cdd76982b1abf69974f3ed9327876df0036 (diff) | |
download | riscv-openocd-60a932b36804bff8b6ca40adc665a33a59475db1.zip riscv-openocd-60a932b36804bff8b6ca40adc665a33a59475db1.tar.gz riscv-openocd-60a932b36804bff8b6ca40adc665a33a59475db1.tar.bz2 |
build: fix memory leaks
Fix the memory leaks found by clang-3.1
Change-Id: Iaae68627ef599c324c9c9ee5737c22e92512862d
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/775
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
Diffstat (limited to 'src/flash')
-rw-r--r-- | src/flash/mflash.c | 1 | ||||
-rw-r--r-- | src/flash/nand/lpc3180.c | 16 | ||||
-rw-r--r-- | src/flash/nor/at91sam7.c | 4 |
3 files changed, 16 insertions, 5 deletions
diff --git a/src/flash/mflash.c b/src/flash/mflash.c index bf61a11..5d1f3b6 100644 --- a/src/flash/mflash.c +++ b/src/flash/mflash.c @@ -770,6 +770,7 @@ COMMAND_HANDLER(mg_write_cmd) int retval = fileio_size(&fileio, &filesize); if (retval != ERROR_OK) { fileio_close(&fileio); + free(buffer); return retval; } diff --git a/src/flash/nand/lpc3180.c b/src/flash/nand/lpc3180.c index 1b53067..a44f3c2 100644 --- a/src/flash/nand/lpc3180.c +++ b/src/flash/nand/lpc3180.c @@ -524,8 +524,9 @@ static int lpc3180_write_page(struct nand_device *nand, target_write_u32(target, 0x200b8010, 0x0); if (!lpc3180_controller_ready(nand, 1000)) { - LOG_ERROR( - "timeout while waiting for completion of auto encode cycle"); + LOG_ERROR("timeout while waiting for completion of auto encode cycle"); + free(page_buffer); + free(oob_buffer); return ERROR_NAND_OPERATION_FAILED; } } @@ -536,11 +537,15 @@ static int lpc3180_write_page(struct nand_device *nand, retval = nand_read_status(nand, &status); if (retval != ERROR_OK) { LOG_ERROR("couldn't read status"); + free(page_buffer); + free(oob_buffer); return ERROR_NAND_OPERATION_FAILED; } if (status & NAND_STATUS_FAIL) { LOG_ERROR("write operation didn't pass, status: 0x%2.2x", status); + free(page_buffer); + free(oob_buffer); return ERROR_NAND_OPERATION_FAILED; } @@ -888,8 +893,9 @@ static int lpc3180_read_page(struct nand_device *nand, target_write_u32(target, 0x200b8014, 0xaa55aa55); if (!lpc3180_controller_ready(nand, 1000)) { - LOG_ERROR( - "timeout while waiting for completion of auto decode cycle"); + LOG_ERROR("timeout while waiting for completion of auto decode cycle"); + free(page_buffer); + free(oob_buffer); return ERROR_NAND_OPERATION_FAILED; } @@ -899,6 +905,8 @@ static int lpc3180_read_page(struct nand_device *nand, if (mlc_isr & 0x40) { LOG_ERROR("uncorrectable error detected: 0x%2.2x", (unsigned)mlc_isr); + free(page_buffer); + free(oob_buffer); return ERROR_NAND_OPERATION_FAILED; } diff --git a/src/flash/nor/at91sam7.c b/src/flash/nor/at91sam7.c index 3e99c4a..95ba084 100644 --- a/src/flash/nor/at91sam7.c +++ b/src/flash/nor/at91sam7.c @@ -897,8 +897,10 @@ static int at91sam7_erase(struct flash_bank *bank, int first, int last) for (pos = 0; pos < nbytes; pos++) buffer[pos] = 0xFF; - if (at91sam7_write(bank, buffer, bank->sectors[first].offset, nbytes) != ERROR_OK) + if (at91sam7_write(bank, buffer, bank->sectors[first].offset, nbytes) != ERROR_OK) { + free(buffer); return ERROR_FLASH_OPERATION_FAILED; + } free(buffer); } |