Currently, RAW pattern parsing will cause a `pkt_buf` buffer to be
allocated to store parsed RAW pattern bytes. All error paths handle the
deallocation correctly, and the buffer will then be passed to FDIR filter
create function which also handles the presence of the buffer correctly,
and it is also freed correctly in destroy function.
However, rte_flow_validate will go through the same code path, but will not
call FDIR create/destroy nor even store the pointer, because `meta`
variable inside the flow parsing function will be set to NULL, which will
cause this memory to be leaked (and memset(0)-ed next time we try to
create/validate another flow).
Fix it by freeing the `pkt_buf` when `meta` is NULL.
Additionally, the initial allocation was done using `ice_malloc` macro. It
does not affect anything as `ice_malloc` translates to `rte_zmalloc` anyway
but for consistency, change the allocation to `rte_zmalloc` as well.
Fixes: 25be39cc1760 ("net/ice: enable protocol agnostic flow offloading in
FDIR")
Cc: [email protected]
Signed-off-by: Anatoly Burakov <[email protected]>
Acked-by: Vladimir Medvedkin <[email protected]>
---
drivers/net/intel/ice/ice_fdir_filter.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/intel/ice/ice_fdir_filter.c
b/drivers/net/intel/ice/ice_fdir_filter.c
index f7730ec6ab..da22b65a77 100644
--- a/drivers/net/intel/ice/ice_fdir_filter.c
+++ b/drivers/net/intel/ice/ice_fdir_filter.c
@@ -1938,7 +1938,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter
*ad,
goto raw_error;
}
- u8 *pkt_buf = (u8 *)ice_malloc(&ad->hw, pkt_len + 1);
+ u8 *pkt_buf = (u8 *)rte_zmalloc("raw pkt buf", pkt_len
+ 1, 0);
if (!pkt_buf) {
ret_val = -ENOMEM;
goto raw_error;
@@ -2497,8 +2497,12 @@ ice_fdir_parse(struct ice_adapter *ad,
if (ret)
goto error;
- if (meta)
+ /* if meta is NULL we're validating so the flow won't be stored */
+ if (meta) {
*meta = filter;
+ } else if (filter->pkt_buf != NULL) {
+ rte_free(filter->pkt_buf);
+ }
rte_free(item);
return ret;
--
2.47.3