Skip to content

Commit

Permalink
target/riscv: Prevent dump_field() reading uninitialized memory
Browse files Browse the repository at this point in the history
Change-Id: I9ef8f2c2e9a824aa6595e8f20682c968ae5aed72
Signed-off-by: Tim Newsome <tim@sifive.com>
  • Loading branch information
timsifive committed Oct 30, 2023
1 parent 89260a5 commit e474d1d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/target/riscv/riscv-013.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,20 @@ static unsigned int decode_dm(char *text, unsigned int address, unsigned int dat
context, data);
}
}
if (text)
text[0] = '\0';
return 0;
}

static unsigned int decode_dmi(struct target *target, char *text, unsigned int address,
unsigned int data)
{
dm013_info_t *dm = get_dm(target);
if (!dm)
if (!dm) {
if (text)
text[0] = '\0';
return 0;
}
return decode_dm(text, address - dm->base, data);
}

Expand Down

0 comments on commit e474d1d

Please sign in to comment.