|WARNING| acl: reject rules with inverted range
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Tue Nov 10 08:12:57 CET 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/172791
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-11-10
# DPDK Patch Review
## Correctness Issues
### Errors
**Resource leak on error path in acl_build_rules()**
In `acl_build_rules()`, the `br` array is allocated with `rte_zmalloc()` before the loop:
```c
br = rte_zmalloc(NULL, sizeof(*br) * bcx->acx->num_rules, 0);
if (br == NULL) {
return -ENOMEM;
}
```
However, the new validation code adds an early return inside the loop that does not free `br`:
```c
if (acl_check_rule_ranges(&bcx->cfg, rule) != 0)
return -EINVAL;
```
This leaks the allocated `br` memory if the range validation fails.
**Fix:** Change the error return to `goto error_free` or similar cleanup label that frees `br`, or assign the error to a return variable and break from the loop to reach existing cleanup code.
---
## Style Issues
### Warnings
**Missing blank line between declarations and statements**
In `test_invalid_rules()` at line 1276-1277:
```c
struct rte_acl_ipv4vlan_rule rule;
struct acl_ipv4vlan_rule rv;
```
The new `rv` variable declaration is added immediately after `rule` with no blank line before the first executable statement. DPDK style requires an empty line between the last declaration and the first statement in a block.
However, reviewing the full context: if there are already statements present before this point in the function (from the existing code not shown in the patch), then adding `rv` here is just extending the declaration block, which is acceptable. The patch context doesn't show enough to definitively confirm a violation. This is a low-confidence flag.
**Actually:** Upon re-reading, the patch shows declarations together with no statements between them, so this is likely not a violation. Omitting this finding.
---
**Inconsistent comparison style**
In `acl_check_rule_ranges()`:
```c
if (cfg->defs[n].type != RTE_ACL_FIELD_TYPE_RANGE)
continue;
```
This should use explicit comparison for consistency with DPDK style patterns. However, this is comparing an enum constant, not NULL/0/'\0', so the explicit comparison guideline does not strictly apply. This is acceptable as-is.
---
## Info
**Pre-existing: Missing explicit NULL comparison in acl_build_rules()**
The existing code at the allocation check:
```c
if (br == NULL) {
```
is correct and follows DPDK style (explicit NULL comparison). This is not an issue.
**Pre-existing: Loop variable could use C99 declaration style**
The existing loop in `acl_build_rules()`:
```c
for (i = 0; i != bcx->acx->num_rules; i++) {
```
uses a pre-declared `i`. DPDK allows both declaration-at-start and C99-style `for (uint32_t i = 0; ...)`. Not a finding.
---
## Test Coverage
The patch adds a test case for inverted ranges via the generic API, which is appropriate. The test verifies that `rte_acl_build()` returns `-EINVAL` for the invalid rule, matching the fix.
---
## Documentation
No user-visible API changes are introduced. The change rejects previously-accepted invalid input that would have caused a crash or incorrect behavior. Release notes are not required for internal bug fixes that don't change API semantics.
---
## Final Assessment
The patch introduces a **resource leak** when validation fails inside the loop in `acl_build_rules()`. The allocated `br` buffer is not freed before the early `return -EINVAL`.
Review-Result: ERROR
More information about the test-report
mailing list