Skip to content

Commit

Permalink
bcachefs: Fix bch2_acl_chmod() cleanup on error
Browse files Browse the repository at this point in the history
Avoid calling kfree on the returned error pointer if
bch2_acl_from_disk fails.

Signed-off-by: Dan Robertson <[email protected]>
  • Loading branch information
dlrobertson authored and koverstreet committed Jun 25, 2021
1 parent c7dea9c commit 21578ad
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/bcachefs/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ int bch2_acl_chmod(struct btree_trans *trans,
acl = bch2_acl_from_disk(xattr_val(xattr.v),
le16_to_cpu(xattr.v->x_val_len));
ret = PTR_ERR_OR_ZERO(acl);
if (ret || !acl)
if (IS_ERR_OR_NULL(acl))
goto err;

ret = __posix_acl_chmod(&acl, GFP_KERNEL, mode);
Expand All @@ -389,7 +389,8 @@ int bch2_acl_chmod(struct btree_trans *trans,
acl = NULL;
err:
bch2_trans_iter_put(trans, iter);
kfree(acl);
if (!IS_ERR_OR_NULL(acl))
kfree(acl);
return ret;
}

Expand Down

0 comments on commit 21578ad

Please sign in to comment.