]> git.ipfire.org Git - thirdparty/linux.git/blobdiff - net/sctp/sm_make_chunk.c
sctp: Free cookie before we memdup a new one
[thirdparty/linux.git] / net / sctp / sm_make_chunk.c
index f17908f5c4f3c52c21614e24316f2e17c6fa1742..9b0e5b0d701ad9255327897b119634e1939276c7 100644 (file)
@@ -2583,6 +2583,8 @@ do_addr_param:
        case SCTP_PARAM_STATE_COOKIE:
                asoc->peer.cookie_len =
                        ntohs(param.p->length) - sizeof(struct sctp_paramhdr);
+               if (asoc->peer.cookie)
+                       kfree(asoc->peer.cookie);
                asoc->peer.cookie = kmemdup(param.cookie->body, asoc->peer.cookie_len, gfp);
                if (!asoc->peer.cookie)
                        retval = 0;
@@ -2647,6 +2649,8 @@ do_addr_param:
                        goto fall_through;
 
                /* Save peer's random parameter */
+               if (asoc->peer.peer_random)
+                       kfree(asoc->peer.peer_random);
                asoc->peer.peer_random = kmemdup(param.p,
                                            ntohs(param.p->length), gfp);
                if (!asoc->peer.peer_random) {
@@ -2660,6 +2664,8 @@ do_addr_param:
                        goto fall_through;
 
                /* Save peer's HMAC list */
+               if (asoc->peer.peer_hmacs)
+                       kfree(asoc->peer.peer_hmacs);
                asoc->peer.peer_hmacs = kmemdup(param.p,
                                            ntohs(param.p->length), gfp);
                if (!asoc->peer.peer_hmacs) {
@@ -2675,6 +2681,8 @@ do_addr_param:
                if (!ep->auth_enable)
                        goto fall_through;
 
+               if (asoc->peer.peer_chunks)
+                       kfree(asoc->peer.peer_chunks);
                asoc->peer.peer_chunks = kmemdup(param.p,
                                            ntohs(param.p->length), gfp);
                if (!asoc->peer.peer_chunks)