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 <mbhardwaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3010174
Reviewed-by: Advaya Andhare <aandhare@nvidia.com>
Reviewed-by: Sandeep Trasi <strasi@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Manish Bhardwaj
2023-11-03 20:23:14 +00:00
committed by mobile promotions
parent d6745fa37c
commit ef1bc16ac8

View File

@@ -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)) {