Skip to content

esp_netif: retain RX pbuf free callback (IDFGH-17719)#18656

Open
dhimasardinata wants to merge 2 commits into
espressif:masterfrom
dhimasardinata:fix/esp-netif-pbuf-free-callback
Open

esp_netif: retain RX pbuf free callback (IDFGH-17719)#18656
dhimasardinata wants to merge 2 commits into
espressif:masterfrom
dhimasardinata:fix/esp-netif-pbuf-free-callback

Conversation

@dhimasardinata
Copy link
Copy Markdown

Summary

  • Store the driver RX-buffer free callback and driver handle in each custom pbuf when it is allocated.
  • Keep delayed pbuf_free() independent from later esp_netif driver config teardown.
  • Add an esp_netif regression test that clears the driver config before freeing the custom pbuf.

Root cause

esp_pbuf_allocate() kept an esp_netif_t * inside the custom pbuf. If the netif driver config was cleared before a queued pbuf was drained, esp_pbuf_free() could later call through the cleared/stale esp_netif->driver_free_rx_buffer path.

Verification

  • git diff --check
  • idf.py -C examples/wifi/getting_started/station -B /tmp/espnetif_pbuf_station_build -D SDKCONFIG=/tmp/espnetif_pbuf_station_sdkconfig set-target esp32 build
  • idf.py -C components/esp_netif/test_apps/test_app_esp_netif -B /tmp/espnetif_test_app_build -D SDKCONFIG=/tmp/espnetif_test_app_sdkconfig set-target esp32 build

Refs espressif/arduino-esp32#12517

Store the driver RX-buffer free callback and driver handle inside each custom pbuf at allocation time. This keeps delayed pbuf_free() independent from later esp_netif driver config teardown.

Add an esp_netif regression test that clears the driver config before freeing a custom pbuf.
@github-actions github-actions Bot changed the title esp_netif: retain RX pbuf free callback esp_netif: retain RX pbuf free callback (IDFGH-17719) May 26, 2026
@espressif-bot espressif-bot added the Status: Opened Issue is new label May 26, 2026
Comment thread components/esp_netif/lwip/netif/esp_pbuf_ref.c
Comment thread components/esp_netif/lwip/netif/esp_pbuf_ref.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Opened Issue is new

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants