]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
net: sctp: sctp_auth_make_key_vector: use sctp_auth_create_key
authorDaniel Borkmann <dborkman@redhat.com>
Thu, 7 Feb 2013 23:22:58 +0000 (23:22 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 8 Feb 2013 22:55:48 +0000 (17:55 -0500)
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>
net/sctp/auth.c

index 94a12de586918a5942494398fc2aa8e8265ca9df..5ec7509bb2c9ed86093ebac1b4c0f5c7cb935a3e 100644 (file)
@@ -209,12 +209,10 @@ static struct sctp_auth_bytes *sctp_auth_make_key_vector(
 
        len = random_len + hmacs_len + chunks_len;
 
-       new = kmalloc(sizeof(struct sctp_auth_bytes) + len, gfp);
+       new = sctp_auth_create_key(len, gfp);
        if (!new)
                return NULL;
 
-       new->len = len;
-
        memcpy(new->data, random, random_len);
        offset += random_len;
 
@@ -353,8 +351,8 @@ static struct sctp_auth_bytes *sctp_auth_asoc_create_secret(
        secret = sctp_auth_asoc_set_secret(ep_key, first_vector, last_vector,
                                            gfp);
 out:
-       kfree(local_key_vector);
-       kfree(peer_key_vector);
+       sctp_auth_key_put(local_key_vector);
+       sctp_auth_key_put(peer_key_vector);
 
        return secret;
 }