From 21578ad8d36892d34ac7b85544e8afc8af8f600a Mon Sep 17 00:00:00 2001 From: Dan Robertson Date: Wed, 23 Jun 2021 21:52:41 -0400 Subject: [PATCH] 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 --- fs/bcachefs/acl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/bcachefs/acl.c b/fs/bcachefs/acl.c index 74cb188f74c60..5408a9225fe50 100644 --- a/fs/bcachefs/acl.c +++ b/fs/bcachefs/acl.c @@ -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); @@ -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; }