netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vlad Yasevich <vyasevich@gmail.com>
To: Daniel Borkmann <dborkman@redhat.com>
Cc: davem@davemloft.net, linux-sctp@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH net-next] net: sctp: sctp_auth_make_key_vector: use sctp_auth_create_key
Date: Fri, 08 Feb 2013 10:01:48 -0500	[thread overview]
Message-ID: <5115135C.6050601@gmail.com> (raw)
In-Reply-To: <783e1129996c3f09c7da121f5dd91c8ac7ba5baa.1360314390.git.dborkman@redhat.com>

On 02/08/2013 04:22 AM, Daniel Borkmann wrote:
> 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>

-vlad

> ---
>   net/sctp/auth.c | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/net/sctp/auth.c b/net/sctp/auth.c
> index 94a12de..5ec7509 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(
>
>   	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;
>   }
>

  reply	other threads:[~2013-02-08 15:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1360314390.git.dborkman@redhat.com>
2013-02-08  9:22 ` [PATCH net-next] net: sctp: sctp_auth_make_key_vector: use sctp_auth_create_key Daniel Borkmann
2013-02-08 15:01   ` Vlad Yasevich [this message]
2013-02-08 22:57   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5115135C.6050601@gmail.com \
    --to=vyasevich@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dborkman@redhat.com \
    --cc=linux-sctp@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).