mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
SAMV7 Ethernet: Fix a write-past-end-of-buffer and trash-the-heap problem
This commit is contained in:
@@ -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 */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user