From 402398b38995798e7c90829395019a60ac7a449a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 16 Mar 2026 10:55:33 -1000 Subject: [PATCH] tweaks --- esphome/components/socket/lwip_raw_tcp_impl.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/esphome/components/socket/lwip_raw_tcp_impl.cpp b/esphome/components/socket/lwip_raw_tcp_impl.cpp index c52241e406d..fa4eb28f31e 100644 --- a/esphome/components/socket/lwip_raw_tcp_impl.cpp +++ b/esphome/components/socket/lwip_raw_tcp_impl.cpp @@ -998,11 +998,13 @@ LWIPRawUDPImpl::LWIPRawUDPImpl(sa_family_t family) : family_(family) { } LWIPRawUDPImpl::~LWIPRawUDPImpl() { + // Early return avoids acquiring the lwip lock when pcb_ is already null + // (e.g., after LWIPRawUDPRecvImpl::close() already cleaned up). + if (this->pcb_ == nullptr) + return; LWIP_LOCK(); - if (this->pcb_ != nullptr) { - udp_remove(this->pcb_); - this->pcb_ = nullptr; - } + udp_remove(this->pcb_); + this->pcb_ = nullptr; } int LWIPRawUDPImpl::bind_internal_locked_(const struct sockaddr *name, socklen_t addrlen) {