Skip to content

Conversation

@ovsrobot
Copy link
Owner

@ovsrobot ovsrobot commented Oct 30, 2025

NOTE: This is an auto submission for "[v3] net/mlx5: fix external Rx and Tx queues access".

See "http://patchwork.dpdk.org/project/dpdk/list/?series=36519" for details.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced network driver robustness by implementing comprehensive null pointer checks for external receive and transmit queue handling, replacing previous assertions with defensive validation and proper error codes to prevent crashes when queues are not properly initialized or configured.

mlx5_ext_rxq_get() and mlx5_ext_txq_get() functions did not return
NULL value if query index was not referencing external queue.

As a result, calling functions did not expect the NULL on return.

External Rx queue:

- In mlx5_ext_rxq_get() remove assert and return NULL if a queue index
  does not point to a valid external queue.

- In mlx5_ext_rxq_verify() validate that probed queue index references
  a valid extern queue.

External Tx queue:

-  In mlx5_ext_txq_get() remove assert and return NULL if a queue index
   does not point to a valid external queue.

- In mlx5_ext_txq_verify() validate that probed queue index references
  a valid extern queue.

Fixes: 311b17e ("net/mlx5: support queue/RSS actions for external Rx queue")

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @ovsrobot, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai
Copy link

coderabbitai bot commented Oct 30, 2025

Walkthrough

The changes add null pointer validation to MLX5 driver functions handling external RX and TX queues. Functions now check for NULL pointers before dereferencing queue handles and return error codes or NULL on absence instead of crashing or asserting.

Changes

Cohort / File(s) Summary
External RXQ null validation
drivers/net/mlx5/mlx5_rxq.c, drivers/net/mlx5/mlx5_devx.c
Replaced assertions and direct dereferences with defensive null checks. mlx5_ext_rxq_get() now returns NULL when external RXQ is absent; mlx5_ext_rxq_verify() safely handles NULL pointers with local lookup guards; mlx5_devx_ind_table_create_rqt_attr() validates external RXQ and returns NULL with EINVAL on absence.
External TXQ null validation
drivers/net/mlx5/mlx5_txq.c, drivers/net/mlx5/mlx5_flow.h
Changed from assuming external TXQ presence to explicit validation. mlx5_ext_txq_get() validates with mlx5_is_external_txq() and returns NULL when not external; flow_hw_get_sqn() checks for NULL handle and returns -EINVAL before dereferencing; mlx5_ext_txq_verify() treats NULL results as non-referenced instead of dereferencing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • The changes follow a consistent defensive programming pattern across multiple files—adding null checks before queue pointer dereferences
  • All modifications are straightforward conditional validations; no complex logic density
  • Primary review focus: verify null checks are placed at appropriate call sites and error codes are handled correctly by callers

Poem

🐰 A hop through the code, a check here, a guard,
No NULL shall pass—this rabbit's on guard!
Where queues once assumed, now we softly peek,
Defensive and safe, no crashes this week! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "[PWCI] "[v3] net/mlx5: fix external Rx and Tx queues access" is directly related to the main changes in the changeset. All four modified files contain changes that address null pointer dereferences and safety checks for external RX and TX queue operations, which aligns perfectly with the title's claim of fixing access to external Rx and Tx queues. The title is concise, specific to the component and resource being fixed, and avoids generic phrasing. The additions of "[PWCI]" and "[v3]" are appropriate for an automated patch submission process.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch series_36519

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39b54f2 and 17ead17.

📒 Files selected for processing (4)
  • drivers/net/mlx5/mlx5_devx.c (1 hunks)
  • drivers/net/mlx5/mlx5_flow.h (1 hunks)
  • drivers/net/mlx5/mlx5_rxq.c (4 hunks)
  • drivers/net/mlx5/mlx5_txq.c (2 hunks)
🔇 Additional comments (8)
drivers/net/mlx5/mlx5_flow.h (1)

2042-2043: LGTM - Defensive NULL check prevents dereference.

The NULL check for ext_txq is necessary and correct. This aligns with the modified behavior of mlx5_ext_txq_get() (in mlx5_txq.c) which now validates external TXQ presence and returns NULL when not external, rather than asserting.

drivers/net/mlx5/mlx5_devx.c (1)

764-768: LGTM - Defensive NULL check with proper resource cleanup.

The NULL check for ext_rxq prevents dereferencing a NULL pointer and correctly includes cleanup of the allocated rqt_attr to avoid memory leak. Setting errno to EINVAL is consistent with the error handling pattern in this file (see line 750).

drivers/net/mlx5/mlx5_txq.c (2)

1284-1285: LGTM - Improved defensive programming replacing assert.

Replacing the MLX5_ASSERT with a conditional check that returns NULL when the queue is not external is a better approach. This enables callers to handle non-external queues gracefully rather than crashing in debug builds. The change is essential for the defensive NULL checks added in mlx5_flow.h (line 2042) and mlx5_devx.c (line 764).


1308-1310: LGTM - Safe iteration pattern with NULL check.

Using mlx5_ext_txq_get() instead of direct array access and checking for NULL before dereferencing is correct. This safely handles iteration over the queue range, skipping non-external queues (where the getter returns NULL) rather than accessing invalid array indices.

drivers/net/mlx5/mlx5_rxq.c (4)

2215-2216: Add null guard to external RxQ reference increment — approved.

The added null check prevents dereferencing a NULL external queue pointer before incrementing its reference count. This is a sound defensive improvement.


2236-2238: Add null handling to external RxQ dereference with UINT32_MAX sentinel — approved.

The conditional ternary safely guards the atomic operation when rxq is NULL, returning UINT32_MAX as a sentinel value rather than attempting to operate on a NULL pointer. This is consistent with defensive error handling patterns.


2257-2258: Add validation check in external RxQ getter — approved.

The updated mlx5_ext_rxq_get() now validates that the index refers to an external RxQ via mlx5_is_external_rxq() before dereferencing the ext_rxqs array. Returns NULL for non-external queues, which is a safe and clear API contract.


2428-2430: Improve external RxQ verification with safe accessor — approved.

The mlx5_ext_rxq_verify() function now uses the safe mlx5_ext_rxq_get() accessor and explicitly checks for NULL before inspecting refcnt. This eliminates a potential NULL dereference and makes the verification logic more robust.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants