SAMV7 Ethernet: Fix a write-past-end-of-buffer and trash-the-heap problem

This commit is contained in:
Gregory Nutt
2015-03-29 16:45:05 -06:00
parent 805be6fee2
commit 8aa133029f
+3 -3
View File
@@ -4563,7 +4563,7 @@ static void sam_rxreset(struct sam_emac_s *priv, int qid)
/* Configure the RX descriptors. */ /* Configure the RX descriptors. */
xfrq->rxndx = 0; xfrq->rxndx = 0;
for (ndx = 0; ndx < priv->attr->nrxbuffers; ndx++) for (ndx = 0; ndx < xfrq->nrxbuffers; ndx++)
{ {
bufaddr = (uintptr_t)&rxbuffer[ndx * xfrq->rxbufsize]; bufaddr = (uintptr_t)&rxbuffer[ndx * xfrq->rxbufsize];
DEBUGASSERT((bufaddr & ~EMACRXD_ADDR_MASK) == 0); DEBUGASSERT((bufaddr & ~EMACRXD_ADDR_MASK) == 0);
@@ -4578,13 +4578,13 @@ static void sam_rxreset(struct sam_emac_s *priv, int qid)
/* Mark the final descriptor in the list */ /* Mark the final descriptor in the list */
rxdesc[priv->attr->nrxbuffers - 1].addr |= EMACRXD_ADDR_WRAP; rxdesc[xfrq->nrxbuffers - 1].addr |= EMACRXD_ADDR_WRAP;
/* Flush the entire RX descriptor table to RAM */ /* Flush the entire RX descriptor table to RAM */
arch_clean_dcache((uintptr_t)rxdesc, arch_clean_dcache((uintptr_t)rxdesc,
(uintptr_t)rxdesc + (uintptr_t)rxdesc +
priv->attr->nrxbuffers * sizeof(struct emac_rxdesc_s)); xfrq->nrxbuffers * sizeof(struct emac_rxdesc_s));
/* Set the Receive Buffer Queue Pointer Register */ /* Set the Receive Buffer Queue Pointer Register */