|WARNING| [v2] net/bnxt: fix parent MAC lookup path handling
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Tue Oct 13 21:31:29 CEST 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/171203
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-10-13
# DPDK Patch Review
## ERRORS
**Missing error check on fopen() allowing use of NULL fp**
The patch introduces a pattern where `fp` is checked for NULL after `fopen()`, but continues execution if the check fails without properly returning. After logging the error on line 166, the code should return immediately rather than falling through to line 170 where `fgets()` would be called with NULL.
```c
fp = fopen(path, "r");
if (!fp) {
BNXT_DRV_DBG(ERR, "Error in getting bond mac address\n");
goto free_glob; // GOOD - current patch does this
}
```
Actually, examining the patch again, the `goto free_glob` is present. This is correct. No error here.
**Potential use-after-free if glob() returns non-zero**
When `glob()` returns non-zero (failure), `gres` is not initialized, but the function returns without calling `globfree()`. On the next invocation, if `glob()` succeeds but the prior state leaked, undefined behavior could occur. However, `gres` is a local variable reinitialized each call, so this is not actually a use-after-free. No error here.
## WARNINGS
**glob_error_fn callback not verified**
The patch uses `glob(..., glob_error_fn, &gres)` but does not show the implementation of `glob_error_fn`. This callback can prevent `glob()` from failing on certain errors. If the callback returns 0 (continue), `glob()` may succeed even when paths cannot be read, potentially leaving `gres.gl_pathv` in an unexpected state. Verify that `glob_error_fn` returns non-zero to abort on errors, ensuring `glob()` failure is properly detected.
## INFO
**Variable initialization of path array**
The `memset(path, 0, sizeof(path))` on line 145 is followed immediately by `snprintf()` on line 146 which writes from the beginning of the buffer. The zero-initialization is unnecessary - `snprintf()` will NUL-terminate. This is a minor inefficiency, not a bug.
**Error message could be more specific**
Line 148: `BNXT_DRV_DBG(ERR, "Error writing path: %s", path);` logs the partially written or potentially uninitialized `path` buffer. When `snprintf()` returns >= sizeof(path), the message should indicate "path truncated" rather than implying a write error occurred. Consider: `"Path truncated: %s", path` or log the intended length.
Review-Result: WARNING
More information about the test-report
mailing list