Skip to content

Commit 03536e2

Browse files
Daniel Borkmanndavem330
authored andcommitted
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 <[email protected]> Acked-by: Vlad Yasevich <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3807ff5 commit 03536e2

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

net/sctp/auth.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,10 @@ static struct sctp_auth_bytes *sctp_auth_make_key_vector(
209209

210210
len = random_len + hmacs_len + chunks_len;
211211

212-
new = kmalloc(sizeof(struct sctp_auth_bytes) + len, gfp);
212+
new = sctp_auth_create_key(len, gfp);
213213
if (!new)
214214
return NULL;
215215

216-
new->len = len;
217-
218216
memcpy(new->data, random, random_len);
219217
offset += random_len;
220218

@@ -353,8 +351,8 @@ static struct sctp_auth_bytes *sctp_auth_asoc_create_secret(
353351
secret = sctp_auth_asoc_set_secret(ep_key, first_vector, last_vector,
354352
gfp);
355353
out:
356-
kfree(local_key_vector);
357-
kfree(peer_key_vector);
354+
sctp_auth_key_put(local_key_vector);
355+
sctp_auth_key_put(peer_key_vector);
358356

359357
return secret;
360358
}

0 commit comments

Comments
 (0)