Skip to content

Commit dc5bfdf

Browse files
Hongbo LiKent Overstreet
authored andcommitted
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: a37ad1a ("bcachefs: sb-clean.c") Signed-off-by: Hongbo Li <[email protected]> Signed-off-by: Kent Overstreet <[email protected]>
1 parent 3125c95 commit dc5bfdf

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/bcachefs/sb-clean.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ struct bch_sb_field_clean *bch2_read_superblock_clean(struct bch_fs *c)
167167

168168
ret = bch2_sb_clean_validate_late(c, clean, READ);
169169
if (ret) {
170+
kfree(clean);
170171
mutex_unlock(&c->sb_lock);
171172
return ERR_PTR(ret);
172173
}

0 commit comments

Comments
 (0)