From 1f3c18fcbe0a62643252e6ec2b72c995eefd02de Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 1 Jan 2017 15:41:53 +0800 Subject: [PATCH] tcp: Make tcp_listen_with_backlog_and_err return NULL if the address/port is already used The caller of tcp_listen_with_backlog_and_err() usually check if the return pcb is NULL before checking the err reason. I think the commit adding tcp_listen_with_backlog_and_err() accidently change the behavior, Fix it. Fixes: 98fc82fa7128 ("added function tcp_listen_with_backlog_and_err() to get the error reason when listening fails") Signed-off-by: Axel Lin --- src/core/tcp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/tcp.c b/src/core/tcp.c index 63e44457..75be86bb 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -684,6 +684,7 @@ tcp_listen_with_backlog_and_err(struct tcp_pcb *pcb, u8_t backlog, err_t *err) if ((lpcb->local_port == pcb->local_port) && ip_addr_cmp(&lpcb->local_ip, &pcb->local_ip)) { /* this address/port is already used */ + lpcb = NULL; res = ERR_USE; goto done; }