target/riscv-011: Fix memory leak in handle_halt_routine()
[openocd.git] / src / target / riscv / riscv-011.c
index f2a68698b1a9cf3bf21f9385e2ef3c95b089e00e..bd3f159fbeebd213683cb8eefc68867f8f695579 100644 (file)
@@ -240,6 +240,7 @@ static unsigned int slot_offset(const struct target *target, slot_t slot)
                                case SLOT1: return 5;
                                case SLOT_LAST: return info->dramsize-1;
                        }
+                       break;
                case 64:
                        switch (slot) {
                                case SLOT0: return 4;
@@ -1787,6 +1788,8 @@ static riscv_error_t handle_halt_routine(struct target *target)
                                        break;
                                default:
                                        assert(0);
+                                       LOG_ERROR("Got invalid register result %d", result);
+                                       goto error;
                        }
                        if (riscv_xlen(target) == 32) {
                                reg_cache_set(target, reg, data & 0xffffffff);
@@ -1803,6 +1806,8 @@ static riscv_error_t handle_halt_routine(struct target *target)
                }
        }
 
+       scans_delete(scans);
+
        if (dbus_busy) {
                increase_dbus_busy_delay(target);
                return RE_AGAIN;
@@ -1816,8 +1821,6 @@ static riscv_error_t handle_halt_routine(struct target *target)
        info->dpc = reg_cache_get(target, CSR_DPC);
        info->dcsr = reg_cache_get(target, CSR_DCSR);
 
-       scans_delete(scans);
-
        cache_invalidate(target);
 
        return RE_OK;

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)