Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential Memory Leak at tee_fs_rpc_opendir of core/tee/tee_fs_rpc.c #1960

Closed
viennadd opened this issue Nov 22, 2017 · 2 comments
Closed

Potential Memory Leak at tee_fs_rpc_opendir of core/tee/tee_fs_rpc.c #1960

viennadd opened this issue Nov 22, 2017 · 2 comments

Comments

@viennadd
Copy link
Contributor

Hi all,

Our code scanner Pinpoint has reported a potential memory leak at the follow:

struct tee_fs_dir *dir = calloc(1, sizeof(*dir));
if (!dir)
return TEE_ERROR_OUT_OF_MEMORY;
va = tee_fs_rpc_cache_alloc(TEE_FS_NAME_MAX, &mobj, &cookie);
if (!va) {
res = TEE_ERROR_OUT_OF_MEMORY;
goto err_exit;
}
op.params[0].attr = OPTEE_MSG_ATTR_TYPE_VALUE_INPUT;
op.params[0].u.value.a = OPTEE_MRF_OPENDIR;
if (!msg_param_init_memparam(op.params + 1, mobj, 0, TEE_FS_NAME_MAX,
cookie, MSG_PARAM_MEM_DIR_IN))
return TEE_ERROR_BAD_STATE;

the early return of return TEE_ERROR_BAD_STATE; at line 380 will leak the memory block pointed by dir (line 364) , could someone have a look and see if it needs a patch ?

Best Regards,
Alex, Sourcebrella Inc.

@jforissier
Copy link
Contributor

Hi @viennadd ,

Thanks for reporting. Indeed, line 380 looks wrong and line 384 also. Would you like to submit a pull request?

viennadd added a commit to viennadd/optee_os that referenced this issue Nov 22, 2017
viennadd added a commit to viennadd/optee_os that referenced this issue Nov 22, 2017
viennadd added a commit to viennadd/optee_os that referenced this issue Nov 22, 2017
@viennadd
Copy link
Contributor Author

viennadd commented Nov 22, 2017

@jforissier Sure, I have added an update on res variable and change the statement from return to goto err_exit in line 380 & line line 384, you might want a double check on the PR.

viennadd added a commit to viennadd/optee_os that referenced this issue Nov 22, 2017
Fixes: OP-TEE#1960
Signed-off-by: ...your name and email here...
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
viennadd added a commit to viennadd/optee_os that referenced this issue Nov 22, 2017
Fixes: OP-TEE#1960
Signed-off-by: Alex CHEN <viennadd@gmail.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
viennadd added a commit to viennadd/optee_os that referenced this issue Nov 22, 2017
Fixes: OP-TEE#1960
Signed-off-by: Alex CHEN <viennadd@gmail.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
takuya-sakata pushed a commit to renesas-rcar/optee_os that referenced this issue May 28, 2018
Fixes: OP-TEE/optee_os#1960
Signed-off-by: Alex CHEN <viennadd@gmail.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
jordanrh1 pushed a commit to ms-iot/optee_os that referenced this issue Oct 16, 2018
Fixes: OP-TEE/optee_os#1960
Signed-off-by: Alex CHEN <viennadd@gmail.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants