summaryrefslogtreecommitdiff
path: root/fs/bcachefs/acl.c
diff options
context:
space:
mode:
authorDan Robertson <dan@dlrobertson.com>2021-06-24 04:52:41 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:07 +0300
commit31029f2f70e6abc833ceefb0f32adf4e7bf42235 (patch)
tree6f7de44514e9f29d2bc1930380e7d9ce6ece0913 /fs/bcachefs/acl.c
parente8e9607f3c1bb927002b7582b68d36c7eb3e92e2 (diff)
downloadlinux-31029f2f70e6abc833ceefb0f32adf4e7bf42235.tar.xz
bcachefs: Fix bch2_acl_chmod() cleanup on error
Avoid calling kfree on the returned error pointer if bch2_acl_from_disk fails. Signed-off-by: Dan Robertson <dan@dlrobertson.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/acl.c')
-rw-r--r--fs/bcachefs/acl.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/bcachefs/acl.c b/fs/bcachefs/acl.c
index be31d27443bc..1642518d3233 100644
--- a/fs/bcachefs/acl.c
+++ b/fs/bcachefs/acl.c
@@ -372,7 +372,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);
@@ -391,7 +391,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;
}