Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lwiperf: fix double-free of pcb on error #15295

Merged
merged 1 commit into from
Jun 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
lwiperf: fix double-free of pcb on error
  • Loading branch information
hifoolno committed Jun 10, 2022
commit fe13765d1fc235a28a14756477e70c3461fde37a
7 changes: 6 additions & 1 deletion connectivity/lwipstack/lwip/src/apps/lwiperf/lwip_lwiperf.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ lwiperf_tcp_close(lwiperf_state_tcp_t *conn, enum lwiperf_report_type report_typ
/* don't want to wait for free memory here... */
tcp_abort(conn->conn_pcb);
}
} else {
} else if (conn->server_pcb != NULL) {
/* no conn pcb, this is the listener pcb */
err = tcp_close(conn->server_pcb);
LWIP_ASSERT("error", err == ERR_OK);
Expand Down Expand Up @@ -565,6 +565,11 @@ lwiperf_tcp_err(void *arg, err_t err)
{
lwiperf_state_tcp_t *conn = (lwiperf_state_tcp_t *)arg;
LWIP_UNUSED_ARG(err);

/* pcb is already deallocated, prevent double-free */
conn->conn_pcb = NULL;
conn->server_pcb = NULL;

lwiperf_tcp_close(conn, LWIPERF_TCP_ABORTED_REMOTE);
}

Expand Down