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

Fix freed memory use in tee_session_close_and_destroy() #39

Merged
1 commit merged into from
Jan 5, 2016
Merged

Fix freed memory use in tee_session_close_and_destroy() #39

1 commit merged into from
Jan 5, 2016

Conversation

pascal-brand38
Copy link
Contributor

The following code is wrong as shm->tee is unpredictable
because of the former free():
devm_kfree(_DEV(tee), sess);
[...]
mutex_unlock(&sess->ctx->tee->lock);

It is fixed in
tee_shm_free(shm);
devm_kfree(_DEV(tee), sess);
[...]
mutex_unlock(&tee->lock);

Signed-off-by: Pascal Brand [email protected]

@@ -392,7 +392,7 @@ int tee_session_close_and_destroy(struct tee_session *sess)
devm_kfree(_DEV(tee), sess);
tee_context_put(ctx);
tee_put(tee);
mutex_unlock(&sess->ctx->tee->lock);
mutex_unlock(&tee->lock);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The argument for mutex_lock() above should also be &tee->lock for easier matching.

@pascal-brand38
Copy link
Contributor Author

Updated

@jenswi-linaro
Copy link
Contributor

Reviewed-by: Jens Wiklander <[email protected]>

The following code is wrong as shm->tee is unpredictable
because of the former free():
    devm_kfree(_DEV(tee), sess);
    [...]
    mutex_unlock(&sess->ctx->tee->lock);

It is fixed in
    devm_kfree(_DEV(tee), sess);
    [...]
    mutex_unlock(&tee->lock);

Reviewed-by: Jens Wiklander <[email protected]>
Signed-off-by: Pascal Brand <[email protected]>
@ghost ghost merged commit 5fcce5d into OP-TEE:master Jan 5, 2016
@pascal-brand38 pascal-brand38 deleted the fixfree branch April 25, 2016 10:51
This pull request was closed.
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

Successfully merging this pull request may close these issues.

2 participants