From 1df5ee12e880fcd5a5129c7f0c077abdf2387f5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20de=20Giessen?= Date: Tue, 12 Aug 2025 13:09:24 +0200 Subject: [PATCH] esp32/network_ppp: Stop polling if PPP was disconnected. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When disconnecting from PPP the modem sends a confirmation. This message is received, like all messages, through the poll() method. lwIP may then immediately call our status callback with code PPPERR_USER to indicate the connection was closed. Our callback then immediately proceeds to free the PCB. Thus, during each new iteration of the loop in poll() we must check if we haven't disconnected in the meantime to prevent calling the pppos_input_tcpip with a PCB that is now NULL. Signed-off-by: Daniƫl van de Giessen --- extmod/network_ppp_lwip.c | 2 +- ports/esp32/network_ppp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extmod/network_ppp_lwip.c b/extmod/network_ppp_lwip.c index 15e3ba0292..d7a1cf5e0c 100644 --- a/extmod/network_ppp_lwip.c +++ b/extmod/network_ppp_lwip.c @@ -146,7 +146,7 @@ static mp_obj_t network_ppp_poll(size_t n_args, const mp_obj_t *args) { mp_int_t total_len = 0; mp_obj_t stream; - while ((stream = self->stream) != mp_const_none) { + while (self->state >= STATE_ACTIVE && (stream = self->stream) != mp_const_none) { uint8_t buf[256]; int err; mp_uint_t len = mp_stream_rw(stream, buf, sizeof(buf), &err, 0); diff --git a/ports/esp32/network_ppp.c b/ports/esp32/network_ppp.c index 97536267b8..725d210488 100644 --- a/ports/esp32/network_ppp.c +++ b/ports/esp32/network_ppp.c @@ -154,7 +154,7 @@ static mp_obj_t network_ppp_poll(size_t n_args, const mp_obj_t *args) { mp_int_t total_len = 0; mp_obj_t stream; - while ((stream = self->stream) != mp_const_none) { + while (self->state >= STATE_ACTIVE && (stream = self->stream) != mp_const_none) { uint8_t buf[256]; int err; mp_uint_t len = mp_stream_rw(stream, buf, sizeof(buf), &err, 0);