Skip to content

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

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

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

Conversation

@Zepp-Hanzj

Copy link
Copy Markdown
Contributor

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
  • checkpatch passes

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 12, 2026
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 apache#19306

Signed-off-by: hanzhijian <hanzhijian@zepp.com>
Author: hanzhijian <hanzhijian@zepp.com>
@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

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