|WARNING| net/ixgbe: fix leak of filters on flow create
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Mon Sep 14 16:08:54 CEST 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/169529
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-09-14
# DPDK Patch Review
## Summary
This patch fixes a resource leak in `ixgbe_flow_create()` where hardware filters were programmed before allocating the software flow object. If allocation failed, the hardware filter remained installed with no way for the application to destroy it. The fix reorders operations to allocate software state first, then program hardware.
---
## Errors
### 1. Missing error check could leak hardware filter (ntuple)
**Location:** ntuple filter handling block
The hardware programming call `ixgbe_add_del_ntuple_filter()` can fail after the allocation succeeds. The patch correctly frees the allocation on failure, but if `ixgbe_add_del_ntuple_filter()` has already partially programmed hardware before failing, that hardware state may not be rolled back.
**Why it matters:** If the hardware add function fails after modifying hardware state, the cleanup path only frees memory but doesn't attempt to remove the partial hardware configuration.
**Suggested fix:** Verify whether `ixgbe_add_del_ntuple_filter()` guarantees transactional behavior (no partial state on failure). If not, add a comment explaining the hardware cleanup guarantee or add an explicit hardware cleanup call on the error path.
---
### 2. Missing error check could leak hardware filter (ethertype)
**Location:** ethertype filter handling block
Same issue as #1: `ixgbe_add_del_ethertype_filter()` failure after allocation frees memory but may leave partial hardware state.
**Suggested fix:** Same as #1.
---
### 3. Missing error check could leak hardware filter (syn)
**Location:** syn filter handling block
Same issue: `ixgbe_syn_filter_set()` failure after allocation frees memory but may leave partial hardware state.
**Suggested fix:** Same as #1.
---
### 4. FDIR mask state not rolled back on hardware programming failure
**Location:** FDIR filter handling block
```c
ret = ixgbe_fdir_flow_program(dev, adapter, &fdir_rule,
&first_mask, error);
if (ret) {
rte_free(fdir_rule_ptr);
goto out;
}
/* update global state */
if (first_mask) {
fdir_info->mask_added = TRUE;
fdir_conf->mask = fdir_rule.mask;
}
```
If `ixgbe_fdir_flow_program()` fails, the code correctly frees the allocation and returns the error. However, if `first_mask` was set to `true` by the hardware programming attempt (even though it later failed), the global mask state may have been modified and is not rolled back on this error path.
**Why it matters:** Global `fdir_info->mask_added` could be left in an inconsistent state if hardware programming partially succeeded before failing.
**Suggested fix:** Verify whether `ixgbe_fdir_flow_program()` can set `first_mask` when it returns an error. If so, the error path needs to check and roll back the mask state.
---
### 5. Missing error check could leak hardware filter (L2 tunnel)
**Location:** L2 tunnel filter handling block
Same pattern: `ixgbe_dev_l2_tunnel_filter_add()` failure after allocation frees memory but may leave partial hardware state.
**Suggested fix:** Same as #1.
---
### 6. Missing error check could leak hardware filter (RSS)
**Location:** RSS filter handling block
Same pattern: `ixgbe_config_rss_filter()` failure after allocation frees memory but may leave partial hardware state.
**Suggested fix:** Same as #1.
---
## Warnings
### 1. Allocation error logging inconsistency
**Location:** All allocation failure paths
The patch uses `PMD_DRV_LOG(ERR, "failed to allocate memory")` consistently. This is fine, but the original code did not set `ret = -ENOMEM` in all cases. The patch correctly sets it now for all allocation failures, which is good.
**Note:** This is actually correct in the patch. No change needed.
---
### 2. L2 tunnel error path change could affect error reporting
**Location:** L2 tunnel filter block
**Original code:**
```c
if (!ret) {
ret = ixgbe_dev_l2_tunnel_filter_add(...);
if (!ret) {
/* allocate and return */
}
}
/* fall through to RSS parsing */
```
**New code:**
```c
if (!ret) {
/* allocate first */
ret = ixgbe_dev_l2_tunnel_filter_add(...);
if (ret) {
rte_free(...);
goto out;
}
/* return success */
}
/* RSS parsing follows */
```
The new code correctly returns the L2 tunnel error immediately instead of falling through to RSS parsing (which would overwrite the error code). This is a correctness improvement mentioned in the commit message.
**Note:** This is a positive change, correctly documented in the commit message.
---
### 3. No release notes update
**Location:** Patch series
This is a bug fix for a resource leak in an existing API. According to DPDK guidelines, bug fixes that are backported to stable (which this patch is, given `Cc: stable at dpdk.org`) should have a release notes entry documenting the fix.
**Suggested fix:** Add a "Bug Fixes" section entry to `doc/guides/rel_notes/release_26_XX.rst` describing the fixed resource leak.
---
## Info
### 1. Consider adding a comment explaining the reordering
**Location:** Function-level
The fix reorders allocation and hardware programming across all filter types. A brief function-level comment explaining this pattern would help future maintainers understand why allocation always happens before hardware programming.
**Suggested addition:**
```c
/*
* For all filter types, allocate the software flow object first,
* then program hardware. On hardware programming failure, free
* the allocation. This prevents leaking hardware filters when
* allocation fails (the application has no handle to clean them up).
*/
```
---
### 2. Code structure could be more uniform
**Location:** All filter blocks
The pattern is now consistent across all filter types (allocate - program - free on error - return), which is good. However, each block is still a separate if-statement. Consider whether a function-table approach or helper functions could reduce code duplication in future refactoring (not required for this fix).
---
## Verification Questions for Maintainers
1. Do the `ixgbe_add_del_*` and `ixgbe_*_filter_*` functions guarantee that on error return, no partial hardware state is left behind? If not, the error paths need to explicitly call hardware cleanup functions.
2. Can `ixgbe_fdir_flow_program()` set `first_mask = true` and then return an error? If so, the error path needs to roll back `fdir_info->mask_added`.
3. Should this patch include a release notes entry given the `Cc: stable at dpdk.org` tag?
---
## Conclusion
The patch correctly addresses the primary issue (allocating software state before hardware programming). The main concern is whether hardware programming functions guarantee atomic behavior on failure. If they can leave partial hardware state when returning an error, the cleanup paths are incomplete. Otherwise, the fix is sound.
The missing release notes entry is a minor process issue that should be addressed.
More information about the test-report
mailing list