netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] sctp: sctp should release assoc when sctp_make_abort_user return NULL in sctp_close
@ 2015-12-17 14:30 Xin Long
  2015-12-17 18:29 ` Vlad Yasevich
  0 siblings, 1 reply; 8+ messages in thread
From: Xin Long @ 2015-12-17 14:30 UTC (permalink / raw)
  To: network dev, linux-sctp; +Cc: marcelo.leitner, vyasevic, davem

In sctp_close, sctp_make_abort_user may return NULL because of memory
allocation failure. If this happens, it will bypass any state change
and never free the assoc. The assoc has no chance to be freed and it
will be kept in memory with the state it had even after the socket is
closed by sctp_close().

So if sctp_make_abort_user fails to allocate memory, we should just
free the asoc, as there isn't much else that we can do.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
---
 net/sctp/socket.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 9b6cc6d..267b8f8 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1513,8 +1513,12 @@ static void sctp_close(struct sock *sk, long timeout)
 			struct sctp_chunk *chunk;
 
 			chunk = sctp_make_abort_user(asoc, NULL, 0);
-			if (chunk)
+			if (chunk) {
 				sctp_primitive_ABORT(net, asoc, chunk);
+			} else {
+				sctp_unhash_established(asoc);
+				sctp_association_free(asoc);
+			}
 		} else
 			sctp_primitive_SHUTDOWN(net, asoc, NULL);
 	}
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-12-21 13:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-17 14:30 [PATCH net] sctp: sctp should release assoc when sctp_make_abort_user return NULL in sctp_close Xin Long
2015-12-17 18:29 ` Vlad Yasevich
2015-12-17 19:01   ` Marcelo Ricardo Leitner
2015-12-17 19:33     ` Vlad Yasevich
2015-12-18 14:08       ` Vlad Yasevich
2015-12-18 16:23         ` Marcelo Ricardo Leitner
2015-12-21  9:56           ` Xin Long
2015-12-21 13:45             ` Marcelo Ricardo Leitner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).