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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix freed memory use in tee_session_close_and_destroy()
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 <jens.wiklander@linaro.org>
Signed-off-by: Pascal Brand <pascal.brand@st.com>
  • Loading branch information
Pascal Brand committed Jan 5, 2016
commit 5fcce5d5800a60957141f1d963edfd199480bfcb
4 changes: 2 additions & 2 deletions core/tee_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,14 @@ int tee_session_close_and_destroy(struct tee_session *sess)

ret = tee_session_close_be(sess);

mutex_lock(&sess->ctx->tee->lock);
mutex_lock(&tee->lock);
tee_dec_stats(&tee->stats[TEE_STATS_SESSION_IDX]);
list_del(&sess->entry);

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.


dev_dbg(_DEV(tee), "%s: <\n", __func__);
return ret;
Expand Down