From ef1bc16ac8dcb2ce0cfcdae3c1545cb7949dd20f Mon Sep 17 00:00:00 2001 From: Manish Bhardwaj Date: Fri, 3 Nov 2023 20:23:14 +0000 Subject: [PATCH] nvidia: fix memory leak issue in vse driver fixing memory leak driver by using krealloc API to reutilize the previously allocated memory Bug 4334915 Change-Id: I4ad88f32152da7527033679b1eed414574cad4e5 Signed-off-by: Manish Bhardwaj Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3010174 Reviewed-by: Advaya Andhare Reviewed-by: Sandeep Trasi GVS: Gerrit_Virtual_Submit --- drivers/crypto/tegra-nvvse-cryptodev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/tegra-nvvse-cryptodev.c b/drivers/crypto/tegra-nvvse-cryptodev.c index 98a0d87b..33d320c2 100644 --- a/drivers/crypto/tegra-nvvse-cryptodev.c +++ b/drivers/crypto/tegra-nvvse-cryptodev.c @@ -344,11 +344,12 @@ static int tnvvse_crypto_sha_update(struct tnvvse_crypto_ctx *ctx, else buffer_size = update_ctl->input_buffer_size; - sha_state->in_buf = kzalloc(buffer_size, GFP_KERNEL); + sha_state->in_buf = krealloc(sha_state->in_buf, buffer_size, GFP_KERNEL); if (sha_state->in_buf == NULL) { ret = -ENOMEM; goto stop_sha; } + memset(sha_state->in_buf, 0, buffer_size); /* copy input buffer */ if (copy_from_user((void *)sha_state->in_buf, input_buffer, update_ctl->input_buffer_size)) {