diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2019-12-18 17:34:36 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:33 -0400 |
commit | 187c71f6ab439582c80433ef9e04f615b8c0f576 (patch) | |
tree | ae1be6c73ecc0326718e3f96fd817ac079ae3049 | |
parent | 22502ac23a2eaa3714b77d4a9242df352a9cd0c0 (diff) | |
download | lwn-187c71f6ab439582c80433ef9e04f615b8c0f576.tar.gz lwn-187c71f6ab439582c80433ef9e04f615b8c0f576.zip |
bcachefs: Fix a memory splat
In __bch2_sb_field_resize, when a field's old a new size was 0, we were
doing an invalid write just past the end of the superblock.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/super-io.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c index cd1aa3891c2e..4c1e8571d872 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -54,7 +54,9 @@ static struct bch_sb_field *__bch2_sb_field_resize(struct bch_sb_handle *sb, BUG_ON(get_order(__vstruct_bytes(struct bch_sb, sb_u64s)) > sb->page_order); - if (!f) { + if (!f && !u64s) { + /* nothing to do: */ + } else if (!f) { f = vstruct_last(sb->sb); memset(f, 0, sizeof(u64) * u64s); f->u64s = cpu_to_le32(u64s); |