|WARNING| [v2, 3/3] eal/linux: fix eventfd leaks when enabling interrupts
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Fri Oct 23 15:35:37 CEST 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/171911
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-10-23
# DPDK Patch Review
## Patch 1/3: eal/linux: fix closing of event FDs not owned by EAL
### Correctness
**Error: Resource leak on error path in rte_intr_efd_enable()**
The original code in `rte_intr_efd_enable()` (visible in the diff context) creates eventfds in a loop but does not clean them up if a later iteration fails. Line 1583 shows `return -errno;` after `eventfd()` fails, but at this point some eventfds have already been created in earlier iterations and are not closed. This is a resource leak.
Note: Patch 3/3 fixes this issue, but it exists in the code being modified by patch 1.
**Verification of Patch 1 Fix:**
The patch changes the condition for closing eventfds from:
```c
if (rte_intr_max_intr_get(intr_handle) > rte_intr_nb_efd_get(intr_handle))
```
to:
```c
if (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_VFIO_MSIX)
```
This correctly identifies that only VFIO_MSIX handles own their eventfds. The logic is sound: the original heuristic was indirect and caused EAL to close fds it didn't create.
### Style
No style issues identified.
---
## Patch 2/3: interrupts: warn on leaked event FDs
### Correctness
**Warning: Loop iteration over nb_intr may exceed array bounds**
Line 196-199 in `eal_common_interrupts.c`:
```c
for (int i = 0; i < intr_handle->nb_intr; i++) {
if (intr_handle->efds[i] >= 0)
EAL_LOG(NOTICE, "Some interrupt handle is leaking an event FD: %d (index %d)",
intr_handle->efds[i], i);
}
```
The loop iterates to `nb_intr`, but the code should verify this doesn't exceed the allocated size of the `efds` array. The `efds` array allocation is not visible in this patch, but iterating based on `nb_intr` assumes it is always <= the array capacity. If `nb_intr` can be set incorrectly (e.g., not validated when set), this could read beyond the array bounds.
**Recommendation:** Verify that `nb_intr` cannot exceed the efds array capacity, or add a bounds check here. If the allocation and all setters ensure `nb_intr <= capacity`, then this is acceptable but the invariant should be documented.
### Style
No style issues identified.
### Documentation
The added Doxygen in `rte_interrupts.h` is clear and correctly documents the new behavior.
---
## Patch 3/3: eal/linux: fix eventfd leaks when enabling interrupts
### Correctness
**Error: Repeated enable check only for VFIO_MSIX, not VDEV/EXT**
Lines 1580-1584:
```c
if (rte_intr_nb_efd_get(intr_handle) != 0) {
EAL_LOG(ERR, "Interrupt eventfds are already enabled");
return -EBUSY;
}
```
This check is inside the `if (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_VFIO_MSIX)` block. The VDEV and EXT branches that follow do not have this protection. If a caller enables VDEV/EXT interrupts twice without disabling, the second call may overwrite state or cause leaks depending on driver behavior.
The check should either apply to all handle types (moved before the type switch) or the commit message should explain why only VFIO_MSIX needs it.
**Fix is correct for the eventfd leak on error:**
The patch updates `nb_efd` incrementally at line 1598:
```c
if (rte_intr_efds_index_set(intr_handle, i, fd) ||
rte_intr_nb_efd_set(intr_handle, i + 1)) {
```
This ensures that the error path at line 1630 can close exactly the fds that were created. The cleanup loop at lines 1630-1633 correctly closes all `nb_efd` entries and resets them to -1.
**Error path resets max_intr inconsistently:**
The error path at line 1629-1635 closes and clears `efds[]` entries and resets `nb_efd` to 0, but does NOT reset `max_intr`. If `max_intr` was set at line 1603 before the error, it remains set. A subsequent call to `rte_intr_efd_disable()` will see a non-zero `max_intr` with `nb_efd == 0`, which may cause unexpected behavior.
**Suggested fix:** Add `rte_intr_max_intr_set(intr_handle, 0);` in the error path after line 1634.
### Style
**Info: Variable declaration separation**
Line 1572:
```c
int fd, ret;
```
DPDK style prefers one declaration per line for clarity. This is a minor style preference, not an error.
---
## Summary
**Errors:**
1. **Patch 3**: Repeated enable protection only for VFIO_MSIX; VDEV/EXT lack this check
2. **Patch 3**: Error path does not reset `max_intr`, leaving handle in inconsistent state
**Warnings:**
1. **Patch 2**: Loop over `nb_intr` assumes it is within `efds[]` array bounds; verify or add check
**Info:**
1. **Patch 3**: Multiple variable declarations on one line (`int fd, ret;`) - prefer one per line
---
Review-Result: ERROR
More information about the test-report
mailing list