From: Thorsten Blum Date: Mon, 7 Apr 2025 08:22:47 +0000 (+0200) Subject: crypto: x509 - Replace kmalloc() + NUL-termination with kzalloc() X-Git-Tag: v6.16-rc1~206^2~306 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b93336cd767fc266dcccfa034a1fb32ae1a23564;p=thirdparty%2Fkernel%2Flinux.git crypto: x509 - Replace kmalloc() + NUL-termination with kzalloc() 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 Reviewed-by: Lukas Wunner Signed-off-by: Herbert Xu --- diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c index ee2fdab42334f..2ffe4ae90bea0 100644 --- a/crypto/asymmetric_keys/x509_cert_parser.c +++ b/crypto/asymmetric_keys/x509_cert_parser.c @@ -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; }