arch/assert: fix the stack dump overflow

[ EMERG] kasan_report: kasan detected a read access error, address at 0x3c24fca8, size is 4
[ EMERG] up_assert: Assertion failed at file:kasan/kasan.c line: 104 task: init
[ EMERG] backtrace|10:  0x2c334666 0x2c35f0d6 0x2c359ef6 0x2c35f830 0x2c360ed4 0x2c3615c0 0x2c324e0c 0x2c30a168
[ EMERG] up_registerdump: R0: ffffffff R1: 00000004 R2: ffffffff R3: ffffffff
[ EMERG] up_registerdump: R4: 3c20d4f0 R5: 2c35acd5 R6: 00000000 FP: 3c24fae8
[ EMERG] up_registerdump: R8: 3c20d504 SB: ffffffff SL: 2c413e7c R11: 2c411eb8
[ EMERG] up_registerdump: IP: 00000002 SP: 3c24fae8 LR: 00000003 PC: 2c35f0d6
[ EMERG] up_registerdump: xPSR: 61010000 BASEPRI: 000000e0 CONTROL: 00000004

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2021-12-02 17:44:49 +08:00 committed by Xiang Xiao
parent 4703ef93cc
commit 89e2f00dad
16 changed files with 16 additions and 16 deletions

View File

@ -77,7 +77,7 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
{
uint32_t stack;
for (stack = sp & ~0x1f; stack < stack_top; stack += 32)
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
{
uint32_t *ptr = (uint32_t *)stack;
_alert("%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",

View File

@ -76,7 +76,7 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
{
uint32_t stack;
for (stack = sp & ~0x1f; stack < stack_top; stack += 32)
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
{
uint32_t *ptr = (uint32_t *)stack;
_alert("%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",

View File

@ -79,7 +79,7 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
{
uint32_t stack;
for (stack = sp & ~0x1f; stack < stack_top; stack += 32)
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
{
uint32_t *ptr = (uint32_t *)stack;
_alert("%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",

View File

@ -79,7 +79,7 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
{
uint32_t stack;
for (stack = sp & ~0x1f; stack < stack_top; stack += 32)
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
{
uint32_t *ptr = (uint32_t *)stack;
_alert("%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",

View File

@ -76,7 +76,7 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
{
uint32_t stack;
for (stack = sp & ~0x1f; stack < stack_top; stack += 32)
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
{
uint32_t *ptr = (uint32_t *)stack;
_alert("%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",

View File

@ -79,7 +79,7 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
{
uint32_t stack;
for (stack = sp & ~0x1f; stack < stack_top; stack += 32)
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
{
uint32_t *ptr = (uint32_t *)stack;
_alert("%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",

View File

@ -51,7 +51,7 @@ static void up_stackdump(uint16_t sp, uint16_t stack_top)
{
uint16_t stack;
for (stack = sp & ~3; stack < stack_top; stack += 12)
for (stack = sp & ~3; stack < (stack_top & ~0x1f); stack += 12)
{
uint8_t *ptr = (uint8_t *)stack;
_alert("%04x: %02x %02x %02x %02x %02x %02x %02x %02x"

View File

@ -51,7 +51,7 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
{
uint32_t stack;
for (stack = sp & ~0x1f; stack < stack_top; stack += 32)
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
{
uint32_t *ptr = (uint32_t *)stack;
_alert("%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",

View File

@ -76,7 +76,7 @@ static void up_stackdump(uint16_t sp, uint16_t stack_top)
{
uint16_t stack;
for (stack = sp; stack < stack_top; stack += 16)
for (stack = sp; stack < (stack_top & ~0x1f); stack += 16)
{
uint8_t *ptr = (uint8_t *)stack;

View File

@ -52,7 +52,7 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
{
uint32_t stack;
for (stack = sp & ~0x1f; stack < stack_top; stack += 32)
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
{
uint32_t *ptr = (uint32_t *)stack;
_alert("%08" PRIx32 ": %08" PRIx32 " %08" PRIx32

View File

@ -50,7 +50,7 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
{
uint32_t stack;
for (stack = sp & ~0x1f; stack < stack_top; stack += 32)
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
{
uint32_t *ptr = (uint32_t *)stack;
_alert("%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",

View File

@ -50,7 +50,7 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
{
uint32_t stack;
for (stack = sp & ~0x1f; stack < stack_top; stack += 32)
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
{
uint32_t *ptr = (uint32_t *) stack;
_alert("%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",

View File

@ -75,7 +75,7 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
{
uint32_t stack;
for (stack = sp & ~0x1f; stack < stack_top; stack += 32)
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
{
uint32_t *ptr = (uint32_t *)stack;
_alert("%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",

View File

@ -75,7 +75,7 @@ static void up_stackdump(uint64_t sp, uintptr_t stack_top)
{
uintptr_t stack;
for (stack = sp & ~0x1f; stack < stack_top; stack += 32)
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
{
uint32_t *ptr = (uint32_t *)stack;
_alert("%08" PRIxPTR ": %08" PRIx32 " %08" PRIx32 " %08" PRIx32

View File

@ -77,7 +77,7 @@ static void up_stackdump(uint32_t sp, uint32_t stack_top)
{
uint32_t stack;
for (stack = sp & ~0x1f; stack < stack_top; stack += 32)
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
{
uint32_t *ptr = (uint32_t *)stack;
_alert("%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",

View File

@ -69,7 +69,7 @@ static void up_stackdump(uint64_t sp, uint64_t stack_top)
{
uint64_t stack;
for (stack = sp & ~0x1f; stack < stack_top; stack += 32)
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
{
uint32_t *ptr = (uint32_t *)stack;
_alert("%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",