This is an automated email from Gerrit.

"Jan Matyas <[email protected]>" just uploaded a new patch set to Gerrit, 
which you can find at https://review.openocd.org/c/openocd/+/9741

-- gerrit

commit 8630c34137d32eaabc4110224c180c754168a430
Author: Jan Matyas <[email protected]>
Date:   Fri Jun 12 15:26:37 2026 +0200

    target/riscv: fix bug in scratch_reserve
    
    This commit fixes comparison in scratch_reserve function.
    
    Original author of this fix is Farid Khaydari, see [1].
    
    [1] https://github.com/riscv-collab/riscv-openocd/
        commit/10f1659f5ef048486acf8ec9925d2c2e2b87f1dd
    
    Change-Id: I64399fb640ffe3a77dd7e6692592e9dcf8986d9b
    Signed-off-by: Farid Khaydari <[email protected]>
    Signed-off-by: Jan Matyas <[email protected]>

diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c
index 318a66ffe0..7ce5dfddf9 100644
--- a/src/target/riscv/riscv-013.c
+++ b/src/target/riscv/riscv-013.c
@@ -1205,7 +1205,7 @@ static int scratch_reserve(struct target *target,
                /* Align. */
                scratch->hart_address = (scratch->hart_address + alignment - 1) 
& ~(alignment - 1);
 
-               if ((size_bytes + scratch->hart_address - info->dataaddr + 3) / 
4 >=
+               if ((size_bytes + scratch->hart_address - info->dataaddr + 3) / 
4 <=
                                info->datasize) {
                        scratch->memory_space = SPACE_DM_DATA;
                        scratch->debug_address = (scratch->hart_address - 
info->dataaddr) / 4;
@@ -1222,7 +1222,7 @@ static int scratch_reserve(struct target *target,
        scratch->hart_address = (info->progbuf_address + program_size + 
alignment - 1) &
                ~(alignment - 1);
        if ((info->progbuf_writable == YNM_YES) &&
-                       ((size_bytes + scratch->hart_address - 
info->progbuf_address + 3) / 4 >=
+                       ((size_bytes + scratch->hart_address - 
info->progbuf_address + 3) / 4 <=
                        info->progbufsize)) {
                scratch->memory_space = SPACE_DMI_PROGBUF;
                scratch->debug_address = (scratch->hart_address - 
info->progbuf_address) / 4;

-- 

Reply via email to