In some error cases, netmap and dpdk pktios were calling
odp_packet_free_multi with zero packets. Moved existing error
check to avoid a free call with zero packets.

Signed-off-by: Petri Savolainen <petri.savolai...@nokia.com>
---
 platform/linux-generic/pktio/dpdk.c   | 10 ++++++----
 platform/linux-generic/pktio/netmap.c | 10 ++++++----
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/platform/linux-generic/pktio/dpdk.c 
b/platform/linux-generic/pktio/dpdk.c
index 11f3509..0eb025a 100644
--- a/platform/linux-generic/pktio/dpdk.c
+++ b/platform/linux-generic/pktio/dpdk.c
@@ -956,10 +956,12 @@ static int dpdk_send(pktio_entry_t *pktio_entry, int 
index,
                        rte_pktmbuf_free(tx_mbufs[i]);
        }
 
-       odp_packet_free_multi(pkt_table, tx_pkts);
-
-       if (odp_unlikely(tx_pkts == 0 && __odp_errno != 0))
-               return -1;
+       if (odp_unlikely(tx_pkts == 0)) {
+               if (__odp_errno != 0)
+                       return -1;
+       } else {
+               odp_packet_free_multi(pkt_table, tx_pkts);
+       }
 
        return tx_pkts;
 }
diff --git a/platform/linux-generic/pktio/netmap.c 
b/platform/linux-generic/pktio/netmap.c
index 412beec..c1cdf72 100644
--- a/platform/linux-generic/pktio/netmap.c
+++ b/platform/linux-generic/pktio/netmap.c
@@ -830,10 +830,12 @@ static int netmap_send(pktio_entry_t *pktio_entry, int 
index,
        if (!pkt_nm->lockless_tx)
                odp_ticketlock_unlock(&pkt_nm->tx_desc_ring[index].s.lock);
 
-       odp_packet_free_multi(pkt_table, nb_tx);
-
-       if (odp_unlikely(nb_tx == 0 && __odp_errno != 0))
-               return -1;
+       if (odp_unlikely(nb_tx == 0)) {
+               if (__odp_errno != 0)
+                       return -1;
+       } else {
+               odp_packet_free_multi(pkt_table, nb_tx);
+       }
 
        return nb_tx;
 }
-- 
2.8.1

Reply via email to