Skip to content

Commit 91e1484

Browse files
GustavoARSilvaherbertx
authored andcommitted
crypto: af_alg - use struct_size() in sock_kfree_s()
Make use of the struct_size() helper instead of an open-coded version in order to avoid any potential type mistakes, in particular in the context in which this code is being used. So, change the following form: sizeof(*sgl) + sizeof(sgl->sg[0]) * (MAX_SGL_ENTS + 1) to : struct_size(sgl, sg, MAX_SGL_ENTS + 1) This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 867659c commit 91e1484

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

crypto/af_alg.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,7 @@ void af_alg_pull_tsgl(struct sock *sk, size_t used, struct scatterlist *dst,
635635
}
636636

637637
list_del(&sgl->list);
638-
sock_kfree_s(sk, sgl, sizeof(*sgl) + sizeof(sgl->sg[0]) *
639-
(MAX_SGL_ENTS + 1));
638+
sock_kfree_s(sk, sgl, struct_size(sgl, sg, MAX_SGL_ENTS + 1));
640639
}
641640

642641
if (!ctx->used)

0 commit comments

Comments
 (0)