|WARNING| [2/2] net/i40e: fix FDIR memzone leak
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Fri Oct 23 13:15:05 CEST 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/171889
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-10-23
# DPDK Patch Review
## PATCH 1/2: net/i40e: fix floating VEB leak
### Correctness
**Error: Missing error check on `i40e_veb_release()`**
Line added:
```c
i40e_veb_release(vsi->floating_veb);
```
The patch calls `i40e_veb_release()` but does not check its return value. Looking at the surrounding code, the patch checks the return value of `i40e_vsi_release()` in the loop above:
```c
if (i40e_vsi_release(vsi_list->vsi) != I40E_SUCCESS)
return -1;
```
If `i40e_veb_release()` can fail, the error should be propagated. If it cannot fail or if failure is non-critical in this cleanup path, that should be documented. The asymmetry between checking VSI release but not VEB release suggests the check may be missing.
Suggested fix:
```c
if (i40e_veb_release(vsi->floating_veb) != I40E_SUCCESS)
return -1;
```
**Warning: Potential NULL pointer dereference**
The added line unconditionally dereferences `vsi->floating_veb`. The surrounding code is inside:
```c
if (vsi->floating_veb) {
/* ... loop releasing VSIs ... */
i40e_veb_release(vsi->floating_veb); /* added line */
}
```
This is actually correct - the conditional ensures `floating_veb` is non-NULL before use. However, if `i40e_veb_release()` can fail and leaves `floating_veb` in a partially released state, the pointer should be NULLed afterward to prevent double-free on retry. Since the current code returns -1 on VSI release failure (stopping the process), this may not be an issue in practice, but defensive NULLing is safer in cleanup paths:
```c
i40e_veb_release(vsi->floating_veb);
vsi->floating_veb = NULL;
```
---
## PATCH 2/2: net/i40e: fix FDIR memzone leak
### Correctness
**Error: Use-after-free risk - memzone freed while pointers remain live**
The patch adds:
```c
rte_memzone_free(pf->fdir.prg_mz);
pf->fdir.prg_mz = NULL;
```
However, `pf->fdir.prg_pkt[]` and `pf->fdir.dma_addr[]` are pointers into this memzone (set up in `i40e_fdir_setup()`). After freeing the memzone, these pointers become dangling. If any code path accesses them after teardown (or during teardown if ordering is wrong), this is use-after-free.
The setup code shows:
```c
pf->fdir.prg_pkt[i] = (uint8_t *)mz->addr + I40E_FDIR_PKT_LEN * i;
pf->fdir.dma_addr[i] = mz->iova + I40E_FDIR_PKT_LEN * i;
```
These should be NULLed/zeroed when the memzone is freed:
```c
rte_memzone_free(pf->fdir.prg_mz);
pf->fdir.prg_mz = NULL;
for (i = 0; i < I40E_FDIR_PRG_PKT_CNT; i++) {
pf->fdir.prg_pkt[i] = NULL;
pf->fdir.dma_addr[i] = 0;
}
```
Or, if the entire `pf->fdir` structure is about to be zeroed or the VSI released makes the fdir struct inaccessible, document that ordering.
**Warning: Incomplete teardown symmetry check**
In `i40e_fdir_setup()`, the memzone is allocated with:
```c
mz = rte_memzone_reserve_aligned(z_name, I40E_FDIR_PKT_LEN * I40E_FDIR_PRG_PKT_CNT,
socket_id, RTE_MEMZONE_IOVA_CONTIG,
I40E_CACHE_LINE_SIZE);
```
The patch correctly stores `mz` in `pf->fdir.prg_mz` and frees it in teardown. However, verify that teardown is called in all cleanup paths (normal close, error during init, device removal). The Fixes tag points to setup/teardown functions, so this should be correct, but the reviewer cannot verify all call sites from the patch alone.
---
### Style
Both patches follow DPDK coding style for indentation, brace placement, and line length.
---
### API and Documentation
**Info: Missing release notes update**
Both patches fix resource leaks (correctness bugs) but do not update release notes. While not strictly required for bug fixes in some projects, DPDK typically documents significant bug fixes in the release notes, especially resource leaks that could affect production stability.
Consider adding to `doc/guides/rel_notes/release_XX_YY.rst` under "Fixed Issues" or "Resolved Issues in i40e PMD".
---
## Summary
**Patch 1/2:**
- Missing error check on `i40e_veb_release()` (Error)
- Consider NULLing `vsi->floating_veb` after release for safety (Warning)
**Patch 2/2:**
- `prg_pkt[]` and `dma_addr[]` become dangling pointers after memzone free (Error - use-after-free risk)
- Release notes update recommended (Info)
Review-Result: ERROR
More information about the test-report
mailing list