Commit 60208f79 authored by Xin Long's avatar Xin Long Committed by David S. Miller

sctp: move up sctp_auth_init_hmacs() in sctp_endpoint_init()

sctp_auth_init_hmacs() is called only when ep->auth_enable is set.
It better to move up sctp_auth_init_hmacs() and remove auth_enable
check in it and check auth_enable only once in sctp_endpoint_init().
Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
Acked-by: default avatarNeil Horman <nhorman@tuxdriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 89664c62
...@@ -471,12 +471,6 @@ int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp) ...@@ -471,12 +471,6 @@ int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp)
struct crypto_shash *tfm = NULL; struct crypto_shash *tfm = NULL;
__u16 id; __u16 id;
/* If AUTH extension is disabled, we are done */
if (!ep->auth_enable) {
ep->auth_hmacs = NULL;
return 0;
}
/* If the transforms are already allocated, we are done */ /* If the transforms are already allocated, we are done */
if (ep->auth_hmacs) if (ep->auth_hmacs)
return 0; return 0;
......
...@@ -107,6 +107,13 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, ...@@ -107,6 +107,13 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
auth_chunks->param_hdr.length = auth_chunks->param_hdr.length =
htons(sizeof(struct sctp_paramhdr) + 2); 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. */ /* Initialize the base structure. */
...@@ -150,15 +157,10 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, ...@@ -150,15 +157,10 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
INIT_LIST_HEAD(&ep->endpoint_shared_keys); INIT_LIST_HEAD(&ep->endpoint_shared_keys);
null_key = sctp_auth_shkey_create(0, gfp); null_key = sctp_auth_shkey_create(0, gfp);
if (!null_key) if (!null_key)
goto nomem; goto nomem_shkey;
list_add(&null_key->key_list, &ep->endpoint_shared_keys); 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 /* Add the null key to the endpoint shared keys list and
* set the hmcas and chunks pointers. * set the hmcas and chunks pointers.
*/ */
...@@ -169,8 +171,8 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, ...@@ -169,8 +171,8 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
return ep; return ep;
nomem_hmacs: nomem_shkey:
sctp_auth_destroy_keys(&ep->endpoint_shared_keys); sctp_auth_destroy_hmacs(ep->auth_hmacs);
nomem: nomem:
/* Free all allocations */ /* Free all allocations */
kfree(auth_hmacs); kfree(auth_hmacs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment