From 2d0f1b85e39aec00aafcd7a9e2b6ce762bc6e141 Mon Sep 17 00:00:00 2001 From: Harri Luhtala Date: Tue, 25 Sep 2018 07:02:04 -0600 Subject: [PATCH] net/tcp/tcp_wrbuffer.c: fix buffer release handling on failed buffer alloc. Attempt to release write buffer on failed TCP write I/O buffer alloc and tryalloc failed to wrb->wb_iob assertion. --- net/tcp/tcp_wrbuffer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/tcp/tcp_wrbuffer.c b/net/tcp/tcp_wrbuffer.c index 4e56d1a7a0..d074bffeeb 100644 --- a/net/tcp/tcp_wrbuffer.c +++ b/net/tcp/tcp_wrbuffer.c @@ -252,13 +252,16 @@ FAR struct tcp_wrbuffer_s *tcp_wrbuffer_tryalloc(void) void tcp_wrbuffer_release(FAR struct tcp_wrbuffer_s *wrb) { - DEBUGASSERT(wrb && wrb->wb_iob); + DEBUGASSERT(wrb != NULL); /* To avoid deadlocks, we must following this ordering: Release the I/O * buffer chain first, then the write buffer structure. */ - iob_free_chain(wrb->wb_iob); + if (wrb->wb_iob != NULL) + { + iob_free_chain(wrb->wb_iob); + } /* Then free the write buffer structure */