summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Husted <sigstop@gmail.com>2019-10-09 04:17:06 +0200
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 23:08:29 +0200
commitbf974f92039778d338e265278cb7aeaabf82ec2d (patch)
tree02a5f463707223ce777e725e5f090c9fc7786e7e
parentbcachefs: Fix uninitialized data in bch2_gc_btree() (diff)
downloadlinux-bf974f92039778d338e265278cb7aeaabf82ec2d.tar.xz
linux-bf974f92039778d338e265278cb7aeaabf82ec2d.zip
bcachefs: Initialize journal pad data in bch_replica_entry objects.
Running the filesystem under valgrind exposed some garbage data being written to disk in bch2_journal_super_entries_add_common(), in the portion which encodes bch_replica_entry objects. Signed-off-by: Justin Husted <sigstop@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/super-io.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c
index af6fb90413e9..14ff191ad702 100644
--- a/fs/bcachefs/super-io.c
+++ b/fs/bcachefs/super-io.c
@@ -1030,9 +1030,10 @@ bch2_journal_super_entries_add_common(struct bch_fs *c,
struct jset_entry_data_usage *u =
container_of(entry, struct jset_entry_data_usage, entry);
- memset(u, 0, sizeof(*u));
- u->entry.u64s = DIV_ROUND_UP(sizeof(*u) + e->nr_devs,
- sizeof(u64)) - 1;
+ int u64s = DIV_ROUND_UP(sizeof(*u) + e->nr_devs,
+ sizeof(u64)) - 1;
+ memset(u, 0, u64s * sizeof(u64));
+ u->entry.u64s = u64s;
u->entry.type = BCH_JSET_ENTRY_data_usage;
u->v = cpu_to_le64(c->usage_base->replicas[i]);
unsafe_memcpy(&u->r, e, replicas_entry_bytes(e),