|
12 | 12 | #include "flower/nfp_flower_representor.h" |
13 | 13 | #include "nfp_logs.h" |
14 | 14 |
|
| 15 | +#ifndef LIST_FOREACH_SAFE |
| 16 | +#define LIST_FOREACH_SAFE(var, head, field, tvar) \ |
| 17 | + for ((var) = LIST_FIRST((head)); \ |
| 18 | + (var) && ((tvar) = LIST_NEXT((var), field), 1); \ |
| 19 | + (var) = (tvar)) |
| 20 | +#endif |
| 21 | + |
15 | 22 | #define NFP_MAX_POLICY_CNT NFP_MAX_MTR_CNT |
16 | 23 | #define NFP_MAX_PROFILE_CNT NFP_MAX_MTR_CNT |
17 | 24 |
|
@@ -1124,28 +1131,28 @@ nfp_mtr_priv_init(struct nfp_pf_dev *pf_dev) |
1124 | 1131 | void |
1125 | 1132 | nfp_mtr_priv_uninit(struct nfp_pf_dev *pf_dev) |
1126 | 1133 | { |
1127 | | - struct nfp_mtr *mtr; |
| 1134 | + struct nfp_mtr *mtr, *tmp_mtr; |
1128 | 1135 | struct nfp_mtr_priv *priv; |
1129 | | - struct nfp_mtr_policy *mtr_policy; |
1130 | | - struct nfp_mtr_profile *mtr_profile; |
| 1136 | + struct nfp_mtr_policy *mtr_policy, *tmp_policy; |
| 1137 | + struct nfp_mtr_profile *mtr_profile, *tmp_profile; |
1131 | 1138 | struct nfp_app_fw_flower *app_fw_flower; |
1132 | 1139 |
|
1133 | 1140 | app_fw_flower = NFP_PRIV_TO_APP_FW_FLOWER(pf_dev->app_fw_priv); |
1134 | 1141 | priv = app_fw_flower->mtr_priv; |
1135 | 1142 |
|
1136 | 1143 | rte_eal_alarm_cancel(nfp_mtr_stats_request, (void *)app_fw_flower); |
1137 | 1144 |
|
1138 | | - LIST_FOREACH(mtr, &priv->mtrs, next) { |
| 1145 | + LIST_FOREACH_SAFE(mtr, &priv->mtrs, next, tmp_mtr) { |
1139 | 1146 | LIST_REMOVE(mtr, next); |
1140 | 1147 | rte_free(mtr); |
1141 | 1148 | } |
1142 | 1149 |
|
1143 | | - LIST_FOREACH(mtr_profile, &priv->profiles, next) { |
| 1150 | + LIST_FOREACH_SAFE(mtr_profile, &priv->profiles, next, tmp_profile) { |
1144 | 1151 | LIST_REMOVE(mtr_profile, next); |
1145 | 1152 | rte_free(mtr_profile); |
1146 | 1153 | } |
1147 | 1154 |
|
1148 | | - LIST_FOREACH(mtr_policy, &priv->policies, next) { |
| 1155 | + LIST_FOREACH_SAFE(mtr_policy, &priv->policies, next, tmp_policy) { |
1149 | 1156 | LIST_REMOVE(mtr_policy, next); |
1150 | 1157 | rte_free(mtr_policy); |
1151 | 1158 | } |
|
0 commit comments