|WARNING| [v2,16/16] bus/fslmc: use generic cleanup
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Mon Oct 26 22:11:26 CET 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/172116
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-10-26
# DPDK Patch Review
## Patch 01/16: drivers/bus: cleanup device freeing in NXP bus scan
**No issues found.**
The patch removes `dpaa_clean_device_list()` helper and inlines cleanup logic. Code is straightforward and matches the stated goal.
---
## Patch 02/16: drivers/bus: fix FD leak during scan in NXP drivers
**No issues found.**
Correctly closes file descriptors on error paths before setting interrupt handle FD to -1.
---
## Patch 03/16: bus/dpaa: allocate interrupt during probing
### Errors
1. **Error path resource leak** (line in `dpaa_bus_probe_device`):
```c
ret = dpaa_setup_intr(dpaa_dev->intr_handle);
if (ret != 0) {
DPAA2_BUS_ERR("error setting up interrupt: %s", dpaa_dev->name);
goto release_intr;
}
```
When `dpaa_setup_intr()` fails, the function goes to `release_intr` which calls `rte_intr_instance_free()`. However, if `dpaa_setup_intr()` created an eventfd and stored it in the interrupt handle before failing (which it does on `rte_intr_type_set` failure), that FD is never closed. The `rte_intr_fd_close()` call only happens after a successful driver probe + later unplug, not in this error path.
The fix should call `rte_intr_fd_close()` before `rte_intr_instance_free()` on the `release_intr` label when coming from the `dpaa_setup_intr` failure:
```c
ret = dpaa_drv->probe(dpaa_drv, dpaa_dev);
if (ret != 0) {
DPAA_BUS_ERR("unable to probe: %s", dpaa_dev->name);
rte_intr_fd_close(dpaa_dev->intr_handle);
release_intr:
rte_intr_instance_free(dpaa_dev->intr_handle);
dpaa_dev->intr_handle = NULL;
}
```
Note the `rte_intr_fd_close()` call is needed only when `dpaa_setup_intr` succeeds but probe fails. The current code has no such call.
2. **Missing FD close in dpaa_bus_cleanup error path** (line in `dpaa_bus_cleanup`):
```c
ret = drv->remove(dev);
if (ret < 0) {
rte_errno = errno;
error = -1;
goto next;
}
```
If `drv->remove()` fails, the code jumps to `next:` which then frees the interrupt handle and closes the FD. However, the driver's remove may have left some state inconsistent. More importantly, the `next:` label is reached even on success, so the FD is closed in both success and failure. This is correct. No error here after re-checking.
---
## Patch 04/16: bus/dpaa: support unplug and use generic cleanup
**No issues found.**
The patch correctly implements `unplug_device` and `free_device` callbacks, moving device-specific cleanup to unplug and preserving portal/global cleanup in `dpaa_bus_cleanup()`.
---
## Patch 05/16: bus/fslmc: fix device name leak
**No issues found.**
Stores device name directly in `dev->name` array instead of allocating separately, eliminating the leak.
---
## Patch 06/16: bus/fslmc: fix memory leaks in scan
**No issues found.**
Adds `fslmc_free_device()` helper that frees both the interrupt handle and the device pointer, and uses it consistently to avoid leaks during scan cleanup and device removal.
---
## Patch 07/16: bus/fslmc: fix per type device count
**No issues found.**
Moves device count increment/decrement into the `insert_in_device_list()` and `fslmc_free_device()` helpers so blocklisted devices are correctly excluded from counts.
---
## Patch 08/16: bus/fslmc: fix some VFIO device FD and memory leaks
### Errors
1. **Missing error propagation in fslmc_vfio_close_group** (line 229):
```c
LIST_FOREACH(group, &s_vfio_container.groups, next) {
if (group->fd == vfio_group_fd) {
while (!LIST_EMPTY(&group->vfio_devices)) {
struct fslmc_vfio_device *dev = LIST_FIRST(&group->vfio_devices);
close(dev->fd);
LIST_REMOVE(dev, next);
rte_free(dev);
}
close(vfio_group_fd);
LIST_REMOVE(group, next);
```
The function never checks the return value of `close(dev->fd)` or `close(vfio_group_fd)`. If `close()` fails, the FD remains in the kernel's file descriptor table (though it's removed from the application's list). This is a minor issue since the process is exiting, but for correctness, check and log errors.
However, since the function is already returning an error code (`clear` is set to -1 if the group is not found), and since the existing code does not check `close()` return values elsewhere in the file, this is a **Warning** rather than an **Error** -- the patch does not introduce the problem, and the impact is limited to cleanup on exit.
---
## Patch 09/16: bus/fslmc: fix interrupt leak in DPIO cleanup
**No issues found.**
Correctly closes FDs and frees interrupt handles in `dpaa2_close_dpio_device()` and error paths of `dpaa2_create_dpio_device()`.
---
## Patch 10/16: bus/fslmc: simplify device parsing in scan
**No issues found.**
Refactors string parsing using a table of prefixes and eliminates temporary allocations. Logic is clearer and no leaks.
---
## Patch 11/16: bus/fslmc: release resources on probe failure
**No issues found.**
Adds error unwinding in `rte_fslmc_probe()` that calls `fslmc_vfio_dmaunmap()` and `fslmc_vfio_close_group()` on failure, preventing resource leaks.
---
## Patch 12/16: bus/fslmc: refactor device filtering for multiprocess
**No issues found.**
Splits device lists into control devices (bus infrastructure) and regular devices (ethdev/crypto/dma). Filtering logic is moved to a new `fslmc_filter_control_devices()` helper. The refactor is sound.
---
## Patch 13/16: bus/fslmc: move unplug for some device out of VFIO
**No issues found.**
Moves device unplug from `fslmc_vfio_close_group()` to `rte_fslmc_close()`, separating driver removal from VFIO/interrupt cleanup.
---
## Patch 14/16: bus/fslmc: call VFIO setup for some device from bus layer
**No issues found.**
Introduces `fslmc_vfio_dev_setup()` and `fslmc_vfio_dev_close()` wrappers and calls them from bus probe/close instead of during `fslmc_vfio_process_group()`.
---
## Patch 15/16: bus/fslmc: allocate interrupt during probing
**No issues found.**
Moves interrupt handle allocation from scan to `fslmc_bus_probe_device()`, and correspondingly frees it in `fslmc_bus_unplug_device()`. Matches the pattern established in the DPAA bus earlier in the series.
---
## Patch 16/16: bus/fslmc: use generic cleanup
**No issues found.**
Switches to `rte_bus_generic_cleanup()` and adds a `free_device` callback, completing the migration to the standard bus model.
---
## Summary
**Errors:**
1. **Patch 03/16 (bus/dpaa: allocate interrupt during probing):** FD leak in error path when `dpaa_setup_intr()` succeeds but driver probe fails -- the eventfd opened in `dpaa_setup_intr()` is never closed before freeing the interrupt handle.
**Warnings:**
1. **Patch 08/16 (bus/fslmc: fix some VFIO device FD and memory leaks):** `fslmc_vfio_close_group()` does not check return values of `close()` calls. This is a pre-existing pattern in the file, but ideally should be checked and logged.
---
Review-Result: ERROR
More information about the test-report
mailing list