Skip to content

Commit

Permalink
ovl: clean up error handling in ovl_get_tmpfile()
Browse files Browse the repository at this point in the history
If security_inode_copy_up() fails, it should not set new_creds, so no need
for the cleanup (which would've Oops-ed anyway, due to old_creds being
NULL).

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
  • Loading branch information
Miklos Szeredi committed Oct 26, 2018
1 parent babf477 commit 1f244dc
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions fs/overlayfs/copy_up.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,8 @@ static struct dentry *ovl_get_tmpfile(struct ovl_copy_up_ctx *c)
};

err = security_inode_copy_up(c->dentry, &new_creds);
temp = ERR_PTR(err);
if (err < 0)
goto out;
return ERR_PTR(err);

if (new_creds)
old_creds = override_creds(new_creds);
Expand All @@ -488,7 +487,7 @@ static struct dentry *ovl_get_tmpfile(struct ovl_copy_up_ctx *c)
temp = ovl_do_tmpfile(c->workdir, c->stat.mode);
else
temp = ovl_create_temp(c->workdir, &cattr);
out:

if (new_creds) {
revert_creds(old_creds);
put_cred(new_creds);
Expand Down

0 comments on commit 1f244dc

Please sign in to comment.