summaryrefslogtreecommitdiff
path: root/fs/bcachefs
diff options
context:
space:
mode:
authorHongbo Li <lihongbo22@huawei.com>2024-09-24 09:41:46 +0800
committerKent Overstreet <kent.overstreet@linux.dev>2024-09-27 21:46:34 -0400
commitdc5bfdf8eaed76cf527c9477952c535f75e0e499 (patch)
tree64891dd7cd5ecc37f1414ac39861fd7c00619297 /fs/bcachefs
parent3125c95ea69141c4cbbde854674c90531034ec47 (diff)
bcachefs: fix the memory leak in exception case
The pointer clean points the memory allocated by kmemdup, when the return value of bch2_sb_clean_validate_late is not zero. The memory pointed by clean is leaked. So we should free it in this case. Fixes: a37ad1a3aba9 ("bcachefs: sb-clean.c") Signed-off-by: Hongbo Li <lihongbo22@huawei.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs')
-rw-r--r--fs/bcachefs/sb-clean.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/bcachefs/sb-clean.c b/fs/bcachefs/sb-clean.c
index 025848a9c4c0..005275281804 100644
--- a/fs/bcachefs/sb-clean.c
+++ b/fs/bcachefs/sb-clean.c
@@ -167,6 +167,7 @@ struct bch_sb_field_clean *bch2_read_superblock_clean(struct bch_fs *c)
ret = bch2_sb_clean_validate_late(c, clean, READ);
if (ret) {
+ kfree(clean);
mutex_unlock(&c->sb_lock);
return ERR_PTR(ret);
}