Skip to content

Commit bbeb563

Browse files
SesterhennEricherbertx
authored andcommitted
[CRYPTO] all: Use kzalloc where possible
this patch converts crypto/ to kzalloc usage. Compile tested with allyesconfig. Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent f10b789 commit bbeb563

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

‎crypto/api.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,10 @@ struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
179179
goto out;
180180

181181
tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, flags);
182-
tfm = kmalloc(tfm_size, GFP_KERNEL);
182+
tfm = kzalloc(tfm_size, GFP_KERNEL);
183183
if (tfm == NULL)
184184
goto out_put;
185185

186-
memset(tfm, 0, tfm_size);
187-
188186
tfm->__crt_alg = alg;
189187

190188
if (crypto_init_flags(tfm, flags))

‎crypto/deflate.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,11 @@ static int deflate_decomp_init(struct deflate_ctx *ctx)
7373
int ret = 0;
7474
struct z_stream_s *stream = &ctx->decomp_stream;
7575

76-
stream->workspace = kmalloc(zlib_inflate_workspacesize(), GFP_KERNEL);
76+
stream->workspace = kzalloc(zlib_inflate_workspacesize(), GFP_KERNEL);
7777
if (!stream->workspace ) {
7878
ret = -ENOMEM;
7979
goto out;
8080
}
81-
memset(stream->workspace, 0, zlib_inflate_workspacesize());
8281
ret = zlib_inflateInit2(stream, -DEFLATE_DEF_WINBITS);
8382
if (ret != Z_OK) {
8483
ret = -EINVAL;

0 commit comments

Comments
 (0)