diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-02-07 18:22:58 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-02-08 17:55:48 -0500 |
commit | 03536e23acd3706c0ec93d01dc8bef44dab1a860 (patch) | |
tree | d700c4f069e5fda6cf00fb69fa983ad0b5d800e2 /net/sctp | |
parent | 3807ff5899f892abb4f06747c245fd648a2acdc5 (diff) |
net: sctp: sctp_auth_make_key_vector: use sctp_auth_create_key
In sctp_auth_make_key_vector, we allocate a temporary sctp_auth_bytes
structure with kmalloc instead of the sctp_auth_create_key allocator.
Change this to sctp_auth_create_key as it is the case everywhere else,
so that we also can properly free it via sctp_auth_key_put. This makes
it easier for future code changes in the structure and allocator itself,
since a single API is consistently used for this purpose. Also, by
using sctp_auth_create_key we're doing sanity checks over the arguments.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp')
-rw-r--r-- | net/sctp/auth.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/net/sctp/auth.c b/net/sctp/auth.c index 94a12de58691..5ec7509bb2c9 100644 --- a/net/sctp/auth.c +++ b/net/sctp/auth.c | |||
@@ -209,12 +209,10 @@ static struct sctp_auth_bytes *sctp_auth_make_key_vector( | |||
209 | 209 | ||
210 | len = random_len + hmacs_len + chunks_len; | 210 | len = random_len + hmacs_len + chunks_len; |
211 | 211 | ||
212 | new = kmalloc(sizeof(struct sctp_auth_bytes) + len, gfp); | 212 | new = sctp_auth_create_key(len, gfp); |
213 | if (!new) | 213 | if (!new) |
214 | return NULL; | 214 | return NULL; |
215 | 215 | ||
216 | new->len = len; | ||
217 | |||
218 | memcpy(new->data, random, random_len); | 216 | memcpy(new->data, random, random_len); |
219 | offset += random_len; | 217 | offset += random_len; |
220 | 218 | ||
@@ -353,8 +351,8 @@ static struct sctp_auth_bytes *sctp_auth_asoc_create_secret( | |||
353 | secret = sctp_auth_asoc_set_secret(ep_key, first_vector, last_vector, | 351 | secret = sctp_auth_asoc_set_secret(ep_key, first_vector, last_vector, |
354 | gfp); | 352 | gfp); |
355 | out: | 353 | out: |
356 | kfree(local_key_vector); | 354 | sctp_auth_key_put(local_key_vector); |
357 | kfree(peer_key_vector); | 355 | sctp_auth_key_put(peer_key_vector); |
358 | 356 | ||
359 | return secret; | 357 | return secret; |
360 | } | 358 | } |