arm_backtrace_sp: check the addr after every operation to addr

Should check the addr every time it changed to avoid crash in
backtrace.

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
This commit is contained in:
wangbowen6 2023-05-25 22:23:28 +08:00 committed by Xiang Xiao
parent 264283c5a2
commit 8db4abd5dd

View File

@ -126,6 +126,11 @@ static int backtrace_branch(unsigned long top, unsigned long sp,
}
addr = (addr & ~1) - 2;
if (!in_code_region(addr))
{
continue;
}
ins16 = *(uint16_t *)addr;
if (INSTR_IS(ins16, T_BLX))
{
@ -145,6 +150,11 @@ static int backtrace_branch(unsigned long top, unsigned long sp,
else if ((ins16 & 0xd000) == 0xd000)
{
addr -= 2;
if (!in_code_region(addr))
{
continue;
}
ins16 = *(uint16_t *)addr;
if (INSTR_IS(ins16, T_BL))
{