diff mbox

[NETMAP,02/12] linux-netmap: pktio: fix invalid ring crash

Message ID 1425322017-14636-3-git-send-email-ciprian.barbu@linaro.org
State New
Headers show

Commit Message

Ciprian Barbu March 2, 2015, 6:46 p.m. UTC
Signed-off-by: Ciprian Barbu <ciprian.barbu@linaro.org>
---
 platform/linux-netmap/odp_packet_netmap.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox

Patch

diff --git a/platform/linux-netmap/odp_packet_netmap.c b/platform/linux-netmap/odp_packet_netmap.c
index 6243040..47a15cb 100644
--- a/platform/linux-netmap/odp_packet_netmap.c
+++ b/platform/linux-netmap/odp_packet_netmap.c
@@ -239,6 +239,9 @@  int recv_pkt_netmap(pkt_netmap_t * const pkt_nm, odp_packet_t pkt_table[],
 			rxring = NETMAP_RXRING(pkt_nm->nm_desc->nifp, ringid);
 		}
 
+		if (ringid == pkt_nm->end)
+			break;
+
 		limit = len - nb_rx;
 		if (nm_ring_space(rxring) < limit)
 			limit = nm_ring_space(rxring);
@@ -352,6 +355,9 @@  int send_pkt_netmap(pkt_netmap_t * const pkt_nm, odp_packet_t pkt_table[],
 			txring = NETMAP_TXRING(pkt_nm->nm_desc->nifp, ringid);
 		}
 
+		if (ringid == pkt_nm->end)
+			break;
+
 		limit = len - nb_tx;
 		if (nm_ring_space(txring) < limit)
 			limit = nm_ring_space(txring);