diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-02-27 11:57:42 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:26 -0400 |
commit | 7db4cbd0a52554ddec4cabf2ebd69fc7bcd53a31 (patch) | |
tree | 43eecaf77010dc0f2657ba86c796cd6f94c287ae /fs/bcachefs | |
parent | bf3efff5e4fc2dcd6e6c15578d3f08c301a13229 (diff) |
bcachefs: Fix a memory leak
This fixes a regression from "bcachefs: Heap allocate printbufs" -
bch2_sb_field_validate() was leaking an error string.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs')
-rw-r--r-- | fs/bcachefs/super-io.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c index c616ce5ed194..31b175a8fcd0 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -1423,24 +1423,25 @@ static const struct bch_sb_field_ops *bch2_sb_field_ops[] = { }; static int bch2_sb_field_validate(struct bch_sb *sb, struct bch_sb_field *f, - struct printbuf *orig_err) + struct printbuf *err) { unsigned type = le32_to_cpu(f->type); - struct printbuf err = *orig_err; + struct printbuf field_err = PRINTBUF; int ret; if (type >= BCH_SB_FIELD_NR) return 0; - pr_buf(&err, "Invalid superblock section %s: ", bch2_sb_fields[type]); - - ret = bch2_sb_field_ops[type]->validate(sb, f, &err); + ret = bch2_sb_field_ops[type]->validate(sb, f, &field_err); if (ret) { - pr_newline(&err); - bch2_sb_field_to_text(&err, sb, f); - *orig_err = err; + pr_buf(err, "Invalid superblock section %s: %s", + bch2_sb_fields[type], + field_err.buf); + pr_newline(err); + bch2_sb_field_to_text(err, sb, f); } + printbuf_exit(&field_err); return ret; } |