All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: sctp: sctp_auth_make_key_vector: use sctp_auth_create_key
       [not found] <cover.1360314390.git.dborkman@redhat.com>
@ 2013-02-08  9:22   ` Daniel Borkmann
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Borkmann @ 2013-02-08  9:22 UTC (permalink / raw)
  To: davem; +Cc: linux-sctp, netdev

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>
---
 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;
 }
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next] net: sctp: sctp_auth_make_key_vector: use sctp_auth_create_key
@ 2013-02-08  9:22   ` Daniel Borkmann
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Borkmann @ 2013-02-08  9:22 UTC (permalink / raw)
  To: davem; +Cc: linux-sctp, netdev

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>
---
 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;
 }
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] net: sctp: sctp_auth_make_key_vector: use sctp_auth_create_key
  2013-02-08  9:22   ` Daniel Borkmann
@ 2013-02-08 15:01     ` Vlad Yasevich
  -1 siblings, 0 replies; 6+ messages in thread
From: Vlad Yasevich @ 2013-02-08 15:01 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: davem, linux-sctp, netdev

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;
>   }
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] net: sctp: sctp_auth_make_key_vector: use sctp_auth_create_key
@ 2013-02-08 15:01     ` Vlad Yasevich
  0 siblings, 0 replies; 6+ messages in thread
From: Vlad Yasevich @ 2013-02-08 15:01 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: davem, linux-sctp, netdev

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;
>   }
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] net: sctp: sctp_auth_make_key_vector: use sctp_auth_create_key
  2013-02-08  9:22   ` Daniel Borkmann
@ 2013-02-08 22:57     ` David Miller
  -1 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2013-02-08 22:57 UTC (permalink / raw)
  To: dborkman; +Cc: linux-sctp, netdev

From: Daniel Borkmann <dborkman@redhat.com>
Date: Fri,  8 Feb 2013 10:22:58 +0100

> 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>

Applied.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] net: sctp: sctp_auth_make_key_vector: use sctp_auth_create_key
@ 2013-02-08 22:57     ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2013-02-08 22:57 UTC (permalink / raw)
  To: dborkman; +Cc: linux-sctp, netdev

From: Daniel Borkmann <dborkman@redhat.com>
Date: Fri,  8 Feb 2013 10:22:58 +0100

> 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>

Applied.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-02-08 22:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [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  9:22   ` Daniel Borkmann
2013-02-08 15:01   ` Vlad Yasevich
2013-02-08 15:01     ` Vlad Yasevich
2013-02-08 22:57   ` David Miller
2013-02-08 22:57     ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.