|WARNING| [6/6] devtools: forbid direct use of sys/queue.h

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Thu Sep 17 20:01:46 CEST 2026


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

_AI Code Review_

=== Patch Review: series.patch (via Claude) ===
Review date: 2026-09-17

# DPDK Code Review - series.patch

I've analyzed the patches against the DPDK contribution guidelines. Below are my findings organized by severity.

---

## Patch 1/6: net/bnxt: fix use after free when freeing filters

### Errors

**Use-after-free in bnxt_free_filter_mem (correctness bug)**

The original code freed the filter pointer and then passed it to STAILQ_REMOVE, which must traverse the list to find the element's predecessor. STAILQ_REMOVE accesses `filter->next` after the memory was freed.

Additionally, STAILQ_FOREACH reads the next pointer from the element just freed, causing a second use-after-free in the loop iteration.

**Fix:** The patch correctly addresses both issues by:
1. Using STAILQ_FOREACH_SAFE so iteration doesn't depend on the freed element
2. Moving STAILQ_REMOVE before rte_free()

This is the correct fix.

---

## Patch 2/6: eal: add rte_queue.h with full set of list macros

### Warnings

**Missing SPDX line in new file**

File: `lib/eal/include/rte_queue.h`

The SPDX identifier line exists but is missing the standard formatting. The first line should be:
```c
/* SPDX-License-Identifier: BSD-3-Clause */
```
followed by copyright on the next line. Currently it combines them on one line.

**Documentation: suggest definition list for release notes**

File: `doc/guides/rel_notes/release_26_11.rst`

The bullet list format:
```rst
* **Added rte_queue.h with the full set of list macros.**

  Added ``rte_queue.h``, providing the complete set of BSD queue(3) list
  macros on all platforms, including the ``_FOREACH_SAFE`` variants which
  are not available in the system header on Linux.
  Use it instead of ``<sys/queue.h>``.
```

Could be a definition list for better structure:
```rst
rte_queue.h
   Added ``rte_queue.h``, providing the complete set of BSD queue(3) list
   macros on all platforms, including the ``_FOREACH_SAFE`` variants which
   are not available in the system header on Linux.
   Use it instead of ``<sys/queue.h>``.
```

However, the current bullet list format is acceptable for this type of entry.

---

## Patch 3/6: build: use rte_queue.h instead of sys/queue.h

### No issues found

This patch mechanically replaces `<sys/queue.h>` with `<rte_queue.h>` across the codebase. All changes are consistent and correct.

---

## Patch 4/6: build: remove private FOREACH_SAFE definitions

### No issues found

This patch removes local definitions of `*_FOREACH_SAFE` macros now that they are available from `<rte_queue.h>` on all platforms. All removals are correct.

---

## Patch 5/6: eal: deprecate RTE_TAILQ and RTE_STAILQ macro wrappers

### Warnings

**Deprecation notice formatting**

File: `doc/guides/rel_notes/deprecation.rst`

The deprecation notice correctly documents the macros being deprecated and the timeline. However, it could be clearer that the macros remain available as aliases until removal:

Suggest rewording:
```rst
* eal: The ``RTE_TAILQ_HEAD``, ``RTE_TAILQ_ENTRY``, ``RTE_TAILQ_FOREACH``,
  ``RTE_TAILQ_FIRST``, ``RTE_TAILQ_NEXT``, ``RTE_TAILQ_FOREACH_SAFE``,
  ``RTE_STAILQ_HEAD`` and ``RTE_STAILQ_ENTRY`` macros in ``rte_tailq.h``
  are deprecated and will be removed in DPDK 27.11.
  They remain available as aliases for now but new code should use
  the equivalent ``TAILQ_`` and ``STAILQ_`` macros from ``<rte_queue.h>``,
  which are now available on all platforms.
```

Current wording is acceptable but could be clearer about transition period.

---

## Patch 6/6: devtools: forbid direct use of sys/queue.h

### Errors

**Incorrect file path exclusion in checkpatches.sh**

File: `devtools/checkpatches.sh`

The SKIP_FILES pattern uses a single-quoted string:
```bash
-v SKIP_FILES='lib/eal/include/rte_queue.h'
```

However, the check-forbidden-tokens.awk script likely expects this to be a regex pattern or space-separated list. The single file exception should work, but verify the awk script handles this correctly.

If the awk script expects a regex, it should be:
```bash
-v SKIP_FILES='lib/eal/include/rte_queue\.h'
```

**Recommendation:** Test that the checkpatches.sh addition correctly allows the exception for rte_queue.h itself while blocking other uses.

---

## Summary

**Critical Issues (must fix):**
- None (the use-after-free in patch 1 is being fixed, not introduced)

**Issues Requiring Attention:**
1. SPDX line formatting in rte_queue.h (cosmetic but should match standard format)
2. Verify SKIP_FILES pattern works correctly in checkpatches.sh

**Minor Suggestions:**
1. Deprecation notice wording could be slightly clearer
2. Release notes could use definition list (but current format is acceptable)

The patch series correctly addresses the stated goals: fixing the use-after-free bug and providing a portable queue.h implementation across all platforms. The mechanical changes in patches 3-5 are correct and comprehensive.


More information about the test-report mailing list