diff --git a/src/source-netmap.c b/src/source-netmap.c index 75f8d5d815..fdb4c707e7 100644 --- a/src/source-netmap.c +++ b/src/source-netmap.c @@ -474,7 +474,8 @@ static int NetmapClose(NetmapDevice *dev) pdev->ref--; if (!pdev->ref) { munmap(pdev->mem, pdev->memsize); - for (int i = 0; i <= pdev->rings_cnt; i++) { + // First close SW ring (https://github.com/luigirizzo/netmap/issues/144) + for (int i = pdev->rings_cnt; i >= 0; i--) { NetmapRing *pring = &pdev->rings[i]; close(pring->fd); SCSpinDestroy(&pring->tx_lock);