diff --git a/arch/arm/src/armv7-a/arm_assert.c b/arch/arm/src/armv7-a/arm_assert.c index b5f959016e..eab0e3252d 100644 --- a/arch/arm/src/armv7-a/arm_assert.c +++ b/arch/arm/src/armv7-a/arm_assert.c @@ -200,6 +200,13 @@ static void up_dumpstate(void) * stack? */ + if (sp > istackbase || sp <= istackbase - istacksize) + { + if (up_interrupt_context()) + { + lldbg("ERROR: Stack pointer is not within interrupt stack\n"); + } + } if (sp <= istackbase && sp > istackbase - istacksize) { /* Yes.. dump the interrupt stack */ @@ -231,9 +238,12 @@ static void up_dumpstate(void) if (sp > ustackbase || sp <= ustackbase - ustacksize) { -#if !defined(CONFIG_ARCH_INTERRUPTSTACK) || CONFIG_ARCH_INTERRUPTSTACK < 4 - lldbg("ERROR: Stack pointer is not within allocated stack\n"); +#if defined(CONFIG_ARCH_INTERRUPTSTACK) && CONFIG_ARCH_INTERRUPTSTACK > 3 + if (!up_interrupt_context()) #endif + { + lldbg("ERROR: Stack pointer is not within allocated stack\n"); + } } else { diff --git a/arch/arm/src/sama5/sam_udphs.c b/arch/arm/src/sama5/sam_udphs.c index 16a214168d..501f3cbc93 100644 --- a/arch/arm/src/sama5/sam_udphs.c +++ b/arch/arm/src/sama5/sam_udphs.c @@ -956,7 +956,8 @@ static void sam_dma_wrsetup(struct sam_usbdev_s *priv, struct sam_ep_s *privep, /* How many bytes remain to be transferred in the request? */ - remaining = privreq->req.len - privreq->req.xfrd; + remaining = (int)privreq->req.len - (int)privreq->req.xfrd; + DEBUGASSERT(remaining >= 0 && remaining <= (int)privreq->req.len); /* If there are no bytes to send, then send a zero length packet */ @@ -1020,8 +1021,9 @@ static void sam_dma_rdsetup(struct sam_usbdev_s *priv, /* How many more bytes can we append to the request buffer? */ - remaining = privreq->req.len - privreq->req.xfrd; - DEBUGASSERT(remaining > 0 && privep->epstate == UDPHS_EPSTATE_RECEIVING); + remaining = (int)privreq->req.len - (int)privreq->req.xfrd; + DEBUGASSERT(remaining > 0 && remaining <= (int)privreq->req.len && + privep->epstate == UDPHS_EPSTATE_RECEIVING); /* Clip the DMA transfer size to the size available in the user buffer */