Skip to content

Commit 5e29567

Browse files
Wei Yongjungregkh
authored andcommitted
sctp: fix memory leak of the ASCONF queue when free asoc
[ Upstream commit 8b4472c ] If an ASCONF chunk is outstanding, then the following ASCONF chunk will be queued for later transmission. But when we free the asoc, we forget to free the ASCONF queue at the same time, this will cause memory leak. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 4292346 commit 5e29567

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

net/sctp/associola.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
/* Forward declarations for internal functions. */
6565
static void sctp_assoc_bh_rcv(struct work_struct *work);
6666
static void sctp_assoc_free_asconf_acks(struct sctp_association *asoc);
67+
static void sctp_assoc_free_asconf_queue(struct sctp_association *asoc);
6768

6869
/* Keep track of the new idr low so that we don't re-use association id
6970
* numbers too fast. It is protected by they idr spin lock is in the
@@ -446,6 +447,9 @@ void sctp_association_free(struct sctp_association *asoc)
446447
/* Free any cached ASCONF_ACK chunk. */
447448
sctp_assoc_free_asconf_acks(asoc);
448449

450+
/* Free the ASCONF queue. */
451+
sctp_assoc_free_asconf_queue(asoc);
452+
449453
/* Free any cached ASCONF chunk. */
450454
if (asoc->addip_last_asconf)
451455
sctp_chunk_free(asoc->addip_last_asconf);
@@ -1578,6 +1582,18 @@ int sctp_assoc_set_id(struct sctp_association *asoc, gfp_t gfp)
15781582
return error;
15791583
}
15801584

1585+
/* Free the ASCONF queue */
1586+
static void sctp_assoc_free_asconf_queue(struct sctp_association *asoc)
1587+
{
1588+
struct sctp_chunk *asconf;
1589+
struct sctp_chunk *tmp;
1590+
1591+
list_for_each_entry_safe(asconf, tmp, &asoc->addip_chunk_list, list) {
1592+
list_del_init(&asconf->list);
1593+
sctp_chunk_free(asconf);
1594+
}
1595+
}
1596+
15811597
/* Free asconf_ack cache */
15821598
static void sctp_assoc_free_asconf_acks(struct sctp_association *asoc)
15831599
{

0 commit comments

Comments
 (0)