crypto: x509 - Replace kmalloc() + NUL-termination with kzalloc()
authorThorsten Blum <thorsten.blum@linux.dev>
Mon, 7 Apr 2025 08:22:47 +0000 (10:22 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 16 Apr 2025 07:16:20 +0000 (15:16 +0800)
Use kzalloc() to zero out the one-element array instead of using
kmalloc() followed by a manual NUL-termination.

No functional changes intended.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/asymmetric_keys/x509_cert_parser.c

index ee2fdab42334f1bd3e50c3aee9483148ec834dee..2ffe4ae90bea0e2487385092d4d774be3c2f4774 100644 (file)
@@ -372,10 +372,9 @@ static int x509_fabricate_name(struct x509_parse_context *ctx, size_t hdrlen,
 
        /* Empty name string if no material */
        if (!ctx->cn_size && !ctx->o_size && !ctx->email_size) {
-               buffer = kmalloc(1, GFP_KERNEL);
+               buffer = kzalloc(1, GFP_KERNEL);
                if (!buffer)
                        return -ENOMEM;
-               buffer[0] = 0;
                goto done;
        }