diff --git a/source-netmap.c.orig b/source-netmap.c
index 7393011..207beeb 100644
--- a/source-netmap.c.orig
+++ b/source-netmap.c
@@ -474,7 +478,7 @@ static int NetmapClose(NetmapDevice *dev)
             pdev->ref--;
             if (!pdev->ref) {
                 munmap(pdev->mem, pdev->memsize);
-                for (int i = 0; i <= pdev->rings_cnt; i++) {
+                for (int i = pdev->rings_cnt; i >= 0; i--) {
                     NetmapRing *pring = &pdev->rings[i];
                     close(pring->fd);
                     SCSpinDestroy(&pring->tx_lock);
