net/ice: fix unsafe tailq element removal
authorBeilei Xing <beilei.xing@intel.com>
Fri, 19 Jul 2019 05:28:28 +0000 (13:28 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 23 Jul 2019 12:31:36 +0000 (14:31 +0200)
TAILQ_FOREACH macro is not safe to remove elements
during iterating tailq lists. Replace it with
TAILQ_FOREACH_SAFE.

Fixes: d76116a4678f ("net/ice: add generic flow API")

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
drivers/net/ice/ice_generic_flow.c

index 5725bff..1d07c83 100644 (file)
@@ -13,6 +13,7 @@
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
 #include <rte_malloc.h>
+#include <rte_tailq.h>
 
 #include "ice_ethdev.h"
 #include "ice_generic_flow.h"
@@ -664,9 +665,10 @@ ice_flow_flush(struct rte_eth_dev *dev,
 {
        struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
        struct rte_flow *p_flow;
+       void *temp;
        int ret = 0;
 
-       TAILQ_FOREACH(p_flow, &pf->flow_list, node) {
+       TAILQ_FOREACH_SAFE(p_flow, &pf->flow_list, node, temp) {
                ret = ice_flow_destroy(dev, p_flow, error);
                if (ret) {
                        rte_flow_error_set(error, -ret,