From 0296efdf587efa4eadd7b314c374aba15833a11d Mon Sep 17 00:00:00 2001 From: Steven Date: Wed, 26 Sep 2018 10:14:18 -0700 Subject: vmxnet3: delete interface causes a crash Need to free the buffers starting from ring->consume+1, not ring->consume Make use of the cool API vlib_buffer_free_from_ring Fix a memory leak in vmxnet3_txq_init Change-Id: I0a539ea75211408d84ce433d97a0a0aec5a9618d Signed-off-by: Steven --- src/plugins/vmxnet3/vmxnet3.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/plugins/vmxnet3/vmxnet3.c b/src/plugins/vmxnet3/vmxnet3.c index 2ff6d7969d2..9f2b8a8c596 100644 --- a/src/plugins/vmxnet3/vmxnet3.c +++ b/src/plugins/vmxnet3/vmxnet3.c @@ -274,6 +274,7 @@ vmxnet3_txq_init (vlib_main_t * vm, vmxnet3_device_t * vd, u16 qid, u16 qsz) if (txq->lock == 0) clib_spinlock_init (&txq->lock); vd->flags |= VMXNET3_DEVICE_F_SHARED_TXQ_LOCK; + return 0; } vec_validate_aligned (vd->txqs, qid, CLIB_CACHE_LINE_BYTES); @@ -623,15 +624,9 @@ vmxnet3_delete_if (vlib_main_t * vm, vmxnet3_device_t * vd) vmxnet3_rx_ring *ring; ring = &rxq->rx_ring[rid]; - desc_idx = ring->consume; - while (ring->fill) - { - desc_idx &= mask; - bi = ring->bufs[desc_idx]; - vlib_buffer_free_no_next (vm, &bi, 1); - ring->fill--; - desc_idx++; - } + desc_idx = (ring->consume + 1) & mask; + vlib_buffer_free_from_ring (vm, ring->bufs, desc_idx, rxq->size, + ring->fill); vec_free (ring->bufs); vlib_physmem_free (vm, vmxm->physmem_region, rxq->rx_desc[rid]); } -- cgit 1.2.3-korg