diff mbox series

libpdbg/chip.c: Fix logic error attempting to restore r0 and r1

Message ID 20180813051136.30564-1-alistair@popple.id.au
State Accepted
Headers show
Series libpdbg/chip.c: Fix logic error attempting to restore r0 and r1 | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied
snowpatch_ozlabs/build-multiarch success Test build-multiarch on branch master

Commit Message

Alistair Popple Aug. 13, 2018, 5:11 a.m. UTC
When instruction ramming fails we attempt to restore r0 and r1. This is
unlikely to work as instruction ramming isn't likely to magically start
working if a previous attempt failed. Therefore it is only attempted once
before bailing. However a logic bug in the code meant it would try
indefinitely.

Signed-off-by: Alistair Popple <alistair@popple.id.au>
---
 libpdbg/chip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libpdbg/chip.c b/libpdbg/chip.c
index 079592c..5acda73 100644
--- a/libpdbg/chip.c
+++ b/libpdbg/chip.c
@@ -188,7 +188,7 @@  static int ram_instructions(struct pdbg_target *thread_target, uint64_t *opcodes
 		if (thread->ram_instruction(thread, opcode, &scratch)) {
 			PR_DEBUG("%s: %d, %016" PRIx64 "\n", __FUNCTION__, __LINE__, opcode);
 			exception = 1;
-			if (i >= 0 || i < len)
+			if (i >= 0 && i < len)
 				/* skip the rest and attempt to restore r0 and r1 */
 				i = len - 1;
 			else