Merge tag 'arc-5.2-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc
[sfrench/cifs-2.6.git] / net / sctp / endpointola.c
index 40c7eb941bc9d70fd3db995ae0a8c8176cd7cf7f..e358437ba29ba18403e1d1a5b3a4e19e05da46c1 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /* SCTP kernel implementation
  * Copyright (c) 1999-2000 Cisco, Inc.
  * Copyright (c) 1999-2001 Motorola, Inc.
  *
  * This abstraction represents an SCTP endpoint.
  *
- * The SCTP implementation is free software;
- * you can redistribute it and/or modify it under the terms of
- * the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * The SCTP implementation is distributed in the hope that it
- * will be useful, but WITHOUT ANY WARRANTY; without even the implied
- *                 ************************
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU CC; see the file COPYING.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
  * Please send any bug reports or fixes you make to the
  * email address(es):
  *    lksctp developers <linux-sctp@vger.kernel.org>
@@ -107,6 +92,13 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
                        auth_chunks->param_hdr.length =
                                        htons(sizeof(struct sctp_paramhdr) + 2);
                }
+
+               /* Allocate and initialize transorms arrays for supported
+                * HMACs.
+                */
+               err = sctp_auth_init_hmacs(ep, gfp);
+               if (err)
+                       goto nomem;
        }
 
        /* Initialize the base structure. */
@@ -150,15 +142,10 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
        INIT_LIST_HEAD(&ep->endpoint_shared_keys);
        null_key = sctp_auth_shkey_create(0, gfp);
        if (!null_key)
-               goto nomem;
+               goto nomem_shkey;
 
        list_add(&null_key->key_list, &ep->endpoint_shared_keys);
 
-       /* Allocate and initialize transorms arrays for supported HMACs. */
-       err = sctp_auth_init_hmacs(ep, gfp);
-       if (err)
-               goto nomem_hmacs;
-
        /* Add the null key to the endpoint shared keys list and
         * set the hmcas and chunks pointers.
         */
@@ -169,8 +156,8 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
 
        return ep;
 
-nomem_hmacs:
-       sctp_auth_destroy_keys(&ep->endpoint_shared_keys);
+nomem_shkey:
+       sctp_auth_destroy_hmacs(ep->auth_hmacs);
 nomem:
        /* Free all allocations */
        kfree(auth_hmacs);