From 553d969c4fc6863ff91d2fd95bc223cb765fbef5 Mon Sep 17 00:00:00 2001 From: Sarvesh Bodakhe Date: Wed, 1 Jul 2026 15:49:39 +0530 Subject: [PATCH] fix(nan): pass no event payload to NAN netif bring-up action The NAN-started handler brought the netif up via esp_netif_action_connected() using the NAN-started event's base/event_id/data. Feeding a "connected" action from a "started" event and handing it an unrelated event payload is fragile: it would misbehave if the action handler ever interpreted data (which is not a wifi_event_sta_connected_t here). esp_netif_up() is private to the esp_netif component, so keep the public esp_netif_action_connected() but pass NULL base, 0 event_id, NULL data. This is safe because the NAN netif is not a DHCP client: the handler only calls esp_netif_up() and never reads the event args. --- components/esp_wifi/src/wifi_default.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/components/esp_wifi/src/wifi_default.c b/components/esp_wifi/src/wifi_default.c index 3ba9d6197ab..c73f4294abc 100644 --- a/components/esp_wifi/src/wifi_default.c +++ b/components/esp_wifi/src/wifi_default.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -184,9 +184,10 @@ static void wifi_default_action_nan_started(void *arg, esp_event_base_t base, in if (s_wifi_netifs[WIFI_IF_NAN] != NULL) { wifi_start(s_wifi_netifs[WIFI_IF_NAN], base, event_id, data); esp_nan_action_start(s_wifi_netifs[WIFI_IF_NAN]); - /* Bring the netif up before creating the link-local address; - * esp_netif_create_ip6_linklocal() is a no-op unless netif_is_up(). */ - esp_netif_action_connected(s_wifi_netifs[WIFI_IF_NAN], base, event_id, data); + /* Bring the netif up before esp_netif_create_ip6_linklocal() (a no-op unless + * netif_is_up()). esp_netif_up() is private, so use the public action handler; + * NAN is non-DHCP, so it only calls esp_netif_up() and ignores the event args. */ + esp_netif_action_connected(s_wifi_netifs[WIFI_IF_NAN], NULL, 0, NULL); esp_netif_create_ip6_linklocal(s_wifi_netifs[WIFI_IF_NAN]); } }