From 09c22e13fe565301f883407998708c92a38d6b2f Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Sun, 7 Aug 2016 22:39:16 +0200 Subject: [PATCH] PPP: close link protocol if LCP is not started in ppp_close ppp_close might try to close LCP even if LCP is not started, it happens because because the PPP session might be waiting for the link protocol to come up and we do not check that. We say in the PPP documentation that ppp_close() can be called anytime, so, if link protocol is currently trying to connect, we must cancel the link connection. Fix it by calling the link protocol disconnect callback if LCP is not started yet. --- src/netif/ppp/ppp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index d5de30b2..a1588931 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -341,6 +341,12 @@ ppp_close(ppp_pcb *pcb, u8_t nocarrier) return ERR_INPROGRESS; } + /* LCP not open, close link protocol */ + if (pcb->phase < PPP_PHASE_ESTABLISH) { + ppp_link_terminated(pcb); + return ERR_OK; + } + /* * Only accept carrier lost signal on the stable running phase in order * to prevent changing the PPP phase FSM in transition phases.