|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:27:11 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 Patch Review

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

### Errors

**Use-after-free in `bnxt_free_filter_mem()`**

The `STAILQ_FOREACH` loop reads `filter->next` before freeing `filter`, then `STAILQ_REMOVE` walks the list to unlink it, accessing memory that was just freed.

**Suggested fix:**

The patch correctly uses `STAILQ_FOREACH_SAFE` and moves `STAILQ_REMOVE` before `rte_free()`:

```c
STAILQ_FOREACH_SAFE(filter, &bp->pf->vf_info[i].filter, next,
                    temp_filter) {
    STAILQ_REMOVE(&bp->pf->vf_info[i].filter, filter,
                  bnxt_filter_info, next);
    rte_free(filter);
}
```

This is correct.

---

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

### Warnings

**Release notes use simple list where definition list would be more appropriate**

In `doc/guides/rel_notes/release_26_11.rst`, the bullet item for the new feature is a short description without term/definition structure. This is acceptable as-is; converting it to a definition list is optional.

---

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

### Info

This is a mechanical substitution patch (283 files changed). The correctness depends on patch 2 providing the correct header. No issues found in the substitution itself.

---

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

### Info

This patch removes local copies of `STAILQ_FOREACH_SAFE` and similar macros that were needed before patch 2 introduced `rte_queue.h`. The removals are straightforward and correct.

---

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

### Warnings

**Release notes deprecation notice entry**

The deprecation notice in `doc/guides/rel_notes/deprecation.rst` is correctly formatted and follows the existing style.

**API Changes section**

The `doc/guides/rel_notes/release_26_11.rst` API Changes entry correctly documents the deprecation with the replacement guidance and removal target version (27.11).

**Macro definitions in `rte_tailq.h` are backward-compatible**

The deprecated wrappers are correctly defined in terms of the plain macros (`TAILQ_*`, `STAILQ_*`) rather than the extended ones, ensuring they work even when a system `<sys/queue.h>` was included first and suppressed `rte_queue.h`. The comment explaining this is clear and correct.

---

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

### Warnings

**`check-forbidden-tokens.awk` pattern may produce false positives**

The pattern `include.*<sys/queue.h>` will match:

```c
#include <sys/queue.h>
```

but will also match comments or strings containing the pattern. The existing forbidden-token checks use this same approach, so this is consistent with the codebase, but it is worth noting that future refactoring of the check script may be needed to avoid false positives in comments or quoted strings.

**Documentation example uses incorrect header**

In `doc/guides/contributing/coding_style.rst`, the example changes from:

```c
#include <sys/queue.h>
```

to:

```c
#include <rte_queue.h>
```

This is correct and matches the new guidance.

---

## Summary

### Patch 1/6

**Errors:**
- Use-after-free in `bnxt_free_filter_mem()` (correctly fixed by the patch)

### Patch 2/6

**Warnings:**
- Release notes could use definition list (optional)

### Patches 3, 4

**Info:**
- Mechanical changes, no issues

### Patch 5/6

**Warnings:**
- API deprecation correctly documented
- Backward-compatible macro definitions are correct

### Patch 6/6

**Warnings:**
- Forbidden-token pattern may match comments/strings (consistent with existing checks)
- Documentation example is correct

---

## Overall Assessment

The patch series correctly addresses a real use-after-free bug in patch 1/6 and introduces a portable `rte_queue.h` header to solve the missing `_FOREACH_SAFE` macros on glibc/musl/Windows. The migration is systematic and the deprecated wrappers ensure backward compatibility. The forbidden-token check prevents future regressions.

The only substantive correctness issue is the use-after-free in patch 1/6, which the patch fixes correctly.


More information about the test-report mailing list