Skip to content

drivers/net/w5500: fix wrong variable names in receive error path and d_private assignment#19397

Closed
Zepp-Hanzj wants to merge 1 commit into
apache:masterfrom
Zepp-Hanzj:fix/w5500-defects
Closed

drivers/net/w5500: fix wrong variable names in receive error path and d_private assignment#19397
Zepp-Hanzj wants to merge 1 commit into
apache:masterfrom
Zepp-Hanzj:fix/w5500-defects

Conversation

@Zepp-Hanzj

Copy link
Copy Markdown
Contributor

Summary

Fix two latent defects in the W5500 Ethernet driver:

  1. NETDEV_RXERRORS() references non-existent variables (line 1351): In w5500_receive(), the error path uses &priv->dev but the function parameter is named self and the device field is w_dev. This compiles only because NETDEV_RXERRORS() expands to nothing without CONFIG_NETDEV_STATISTICS; enabling statistics breaks the build.

  2. d_private set to the device array instead of the instance (line 2069): In w5500_initialize(), d_private was set to g_w5500 (the global array) instead of self (the current instance). This is harmless for device 0 (g_w5500 == &g_w5500[0]) but wrong for any devno > 0 — every callback that recovers the driver state via dev->d_private would operate on device 0's state.

Fixes #19306

Impact

  • Bug fix only, no functional changes for single-device configurations
  • Fixes multi-device W5500 configurations where devno > 0
  • Fixes build with CONFIG_NETDEV_STATISTICS enabled

Testing

  • Verified by code inspection against master
  • Confirmed variable names match function signature and struct fields

Signed-off-by: hanzhijian hanzhijian@zepp.com

@github-actions github-actions Bot added Area: Networking Effects networking subsystem Size: XS The size of the change in this PR is very small labels Jul 10, 2026
@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

@acassis acassis requested a review from xiaoxiang781216 July 10, 2026 18:38
@xiaoxiang781216

Copy link
Copy Markdown
Contributor

@Zepp-Hanzj please fix ci warning:

9a0fdb17db drivers/net/w5500: fix wrong variable names in receive error path and d_private assignment
../nuttx/tools/checkpatch.sh -c -u -m -g  e0b4eb7c9cc1df17f6b6471bf531ed38af86b843..HEAD
❌ Commit subject too long > 80
Warning: /home/runner/work/nuttx/nuttx/nuttx/drivers/net/w5500.c:2070:58: warning: Wrong column position of comment right of code
Warning: /home/runner/work/nuttx/nuttx/nuttx/drivers/net/w5500.c:2071:58: warning: Wrong column position of comment right of code
Used config files:
    1: .codespellrc

Fix two latent defects in the W5500 Ethernet driver:

1. In w5500_receive(), NETDEV_RXERRORS() referenced &priv->dev but
   the function parameter is named 'self' and the device field is
   'w_dev'. This compiles only because NETDEV_RXERRORS() expands to
   nothing without CONFIG_NETDEV_STATISTICS; enabling statistics
   breaks the build. Fix: NETDEV_RXERRORS(&self->w_dev).

2. In w5500_initialize(), d_private was set to g_w5500 (the global
   array) instead of self (the current instance). This is harmless
   for device 0 (g_w5500 == &g_w5500[0]) but wrong for any devno > 0
   -- every callback that recovers the driver state via dev->d_private
   would operate on device 0's state.
   Fix: self->w_dev.d_private = self.

Fixes apache#19306

Signed-off-by: hanzhijian <hanzhijian@zepp.com>
Author: hanzhijian <hanzhijian@zepp.com>
@Zepp-Hanzj

Copy link
Copy Markdown
Contributor Author

Closing: needs real hardware verification before submission.

@Zepp-Hanzj Zepp-Hanzj closed this Jul 11, 2026
@Zepp-Hanzj Zepp-Hanzj deleted the fix/w5500-defects branch July 11, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Networking Effects networking subsystem Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] net/w5500: two latent code defects (build break with NETDEV_STATISTICS; wrong d_private)

2 participants