diff mbox series

[RESEND] crypto: x509 - Replace kmalloc() + NUL-termination with kzalloc()

Message ID 20250407082247.741684-1-thorsten.blum@linux.dev (mailing list archive)
State New
Headers show
Series [RESEND] crypto: x509 - Replace kmalloc() + NUL-termination with kzalloc() | expand

Commit Message

Thorsten Blum April 7, 2025, 8:22 a.m. UTC
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>
---
 crypto/asymmetric_keys/x509_cert_parser.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Lukas Wunner April 7, 2025, 8:39 a.m. UTC | #1
On Mon, Apr 07, 2025 at 10:22:47AM +0200, Thorsten Blum wrote:
> 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>
diff mbox series

Patch

diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
index ee2fdab42334..2ffe4ae90bea 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;
 	}