]> git.sur5r.net Git - openocd/commitdiff
flash/nor/stm32: Eliminate working area leak
authorChristopher Head <chead@zaber.com>
Mon, 14 May 2018 20:06:39 +0000 (13:06 -0700)
committerTomas Vanek <vanekt@fbl.cz>
Tue, 3 Jul 2018 06:48:04 +0000 (07:48 +0100)
On a specific early-return path, an allocated working area was not
freed. Free it.

Change-Id: I7c8fe51ff475f191624086996be1c77251780b77
Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/4520
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
src/flash/nor/stm32f1x.c
src/flash/nor/stm32f2x.c
src/flash/nor/stm32h7x.c
src/flash/nor/stm32l4x.c

index 015988a5da34cc97ed9c1c7721e8e5e9a883ad11..faada9a6121fa31a897480e1572679b526c45cf9 100644 (file)
@@ -585,8 +585,10 @@ static int stm32x_write_block(struct flash_bank *bank, const uint8_t *buffer,
 
        retval = target_write_buffer(target, write_algorithm->address,
                        sizeof(stm32x_flash_write_code), stm32x_flash_write_code);
-       if (retval != ERROR_OK)
+       if (retval != ERROR_OK) {
+               target_free_working_area(target, write_algorithm);
                return retval;
+       }
 
        /* memory buffer */
        while (target_alloc_working_area_try(target, buffer_size, &source) != ERROR_OK) {
index 43f5d12d9ec23c3e081211871fe770bb293140c6..413d04d771da1259cf424b03dc88d2c8f52ae138 100644 (file)
@@ -599,8 +599,10 @@ static int stm32x_write_block(struct flash_bank *bank, const uint8_t *buffer,
        retval = target_write_buffer(target, write_algorithm->address,
                        sizeof(stm32x_flash_write_code),
                        stm32x_flash_write_code);
-       if (retval != ERROR_OK)
+       if (retval != ERROR_OK) {
+               target_free_working_area(target, write_algorithm);
                return retval;
+       }
 
        /* memory buffer */
        while (target_alloc_working_area_try(target, buffer_size, &source) != ERROR_OK) {
index 8f34e0475158a9da5df5dfbd147a09817d750641..f2ddaf44730d0a3da5da4cf58f55df395de87f15 100644 (file)
@@ -583,8 +583,10 @@ static int stm32x_write_block(struct flash_bank *bank, const uint8_t *buffer,
        retval = target_write_buffer(target, write_algorithm->address,
                        sizeof(stm32x_flash_write_code),
                        stm32x_flash_write_code);
-       if (retval != ERROR_OK)
+       if (retval != ERROR_OK) {
+               target_free_working_area(target, write_algorithm);
                return retval;
+       }
 
        /* memory buffer */
        while (target_alloc_working_area_try(target, buffer_size, &source) != ERROR_OK) {
index f71369330eb451d6b5a5788d831e88a7e06c6e0a..4fb7e039aa627c7fa82bc2d6b91dc9217d0bc1fa 100644 (file)
@@ -476,8 +476,10 @@ static int stm32l4_write_block(struct flash_bank *bank, const uint8_t *buffer,
        retval = target_write_buffer(target, write_algorithm->address,
                        sizeof(stm32l4_flash_write_code),
                        stm32l4_flash_write_code);
-       if (retval != ERROR_OK)
+       if (retval != ERROR_OK) {
+               target_free_working_area(target, write_algorithm);
                return retval;
+       }
 
        /* memory buffer */
        while (target_alloc_working_area_try(target, buffer_size, &source) !=