|WARNING| [v2] net/bnxt: add bounds checks for FW-supplied IDs

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Tue Oct 13 21:10:30 CEST 2026


Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/171202

_AI Code Review_

=== Patch Review: series.patch (via Claude) ===
Review date: 2026-10-13

# DPDK Patch Review

## ERRORS

**1. Incorrect variable used in phy_port_id bounds check**

```c
if (func->phy_port_id >= port_db->phy_port_cnt) {
    BNXT_DRV_DBG(ERR, "Invalid phy_port_id %u", func->phy_port_id);
    return -EINVAL;
}
```

This check references `func->phy_port_id`, but `func` points to different structures depending on the code path (either the drv_func entry or the vf_func entry), and `phy_port_id` has not been assigned to `func` yet at this point in the function. The patch description states "Check phy_port_id before the parent vnic and MAC address updates", but the code you've read does not show where `func->phy_port_id` is populated prior to this check. If `phy_port_id` comes from firmware and is assigned later (after this check), then this check is validating an uninitialized or stale value. You need to identify where `func->phy_port_id` is set and ensure the bounds check uses the correct source variable at the point where the firmware-supplied value is first consumed.

**2. Missing bounds check on actual firmware-supplied phy_port_id**

The commit message states firmware supplies `phy_port_id` and that bounds checks are added to prevent out-of-bounds access. However, the added check at line 211 validates `func->phy_port_id` after `func` has been assigned to one of the function table entries. The patch does not show where the raw firmware-supplied `phy_port_id` value is first received or used as an array index. If `phy_port_id` is obtained from firmware (e.g., via `bnxt_pmd_get_phy_port_id()` or similar) and used to index `port_db->phy_port_tbl[]`, that indexing operation must have a bounds check at the point of use. The current patch may be checking the wrong variable or checking it too late in the flow.

---

## WARNINGS

**1. Inconsistent bounds check timing for phy_port_id**

The v2 changelog states "Check phy_port_id before the parent vnic and MAC address updates", implying the check was moved earlier. However, without seeing the firmware value assignment, it's unclear whether the check at line 211 actually validates the incoming firmware data before it's used as an index. If `func->phy_port_id` is assigned from firmware earlier in the function (before line 211) and used to index an array, the bounds check should occur immediately after reading the firmware value and before the first indexing operation, not deferred until after other operations.

---

## INFO

None.

---

## SUMMARY

The patch attempts to add bounds checking for firmware-supplied IDs, which is the correct hardening approach. However, the phy_port_id check appears to validate `func->phy_port_id` without showing where this field is populated from the firmware-supplied value. To confirm correctness, you need to:

1. Verify where `phy_port_id` is obtained from firmware (the actual FW response field)
2. Ensure the bounds check is applied to that raw value before it's used as an array index or assigned to `func->phy_port_id`
3. If `func->phy_port_id` is the index used for array access, confirm it's been assigned before line 211

The drv_func_id and vf_func_id checks are correctly placed immediately after retrieval from firmware and before first use.

Review-Result: ERROR


More information about the test-report mailing list