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

core: REE FS: bugfix error path #1801

Merged
merged 1 commit into from
Sep 14, 2017
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
15 changes: 13 additions & 2 deletions core/tee/tee_ree_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,21 @@ static TEE_Result get_dirh(struct tee_fs_dirfile_dirh **dirh)
static void put_dirh_primitive(bool close)
{
assert(ree_fs_dirh_refcount);
assert(ree_fs_dirh);

/*
* During the execution of one of the ree_fs_ops ree_fs_dirh is
* guareteed to be a valid pointer. But when the fop has returned
* another thread may get an error or something causing that fop
* to do a put with close=1.
*
* For all fops but ree_fs_close() there's a call to get_dirh() to
* get a new dirh which will open it again if it was closed before.
* But in the ree_fs_close() case there's no call to get_dirh()
* only to this function, put_dirh_primitive(), and in this case
* ree_fs_dirh may actually be NULL.
*/
ree_fs_dirh_refcount--;
if (!ree_fs_dirh_refcount || close)
if (ree_fs_dirh && (!ree_fs_dirh_refcount || close))
close_dirh(&ree_fs_dirh);
}

Expand Down