]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: Initialize journal pad data in bch_replica_entry objects.
authorJustin Husted <sigstop@gmail.com>
Wed, 9 Oct 2019 02:17:06 +0000 (19:17 -0700)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:29 +0000 (17:08 -0400)
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>
fs/bcachefs/super-io.c

index af6fb90413e95cc7f2e27fb2b16ab9e911e69f94..14ff191ad702402149985768c13783010fd1ff05 100644 (file)
@@ -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),