net/pcap: fix crash on exit for infinite Rx
[dpdk.git] / drivers / net / pcap / rte_eth_pcap.c
index 057aa9d..49764c0 100644 (file)
@@ -748,6 +748,13 @@ eth_dev_close(struct rte_eth_dev *dev)
                        struct pcap_rx_queue *pcap_q = &internals->rx_queue[i];
                        struct rte_mbuf *pcap_buf;
 
+                       /*
+                        * 'pcap_q->pkts' can be NULL if 'eth_dev_close()'
+                        * called before 'eth_rx_queue_setup()' has been called
+                        */
+                       if (pcap_q->pkts == NULL)
+                               continue;
+
                        while (!rte_ring_dequeue(pcap_q->pkts,
                                        (void **)&pcap_buf))
                                rte_pktmbuf_free(pcap_buf);