bcachefs: Add a valgrind memcheck hint
authorBrett Holman <bholman.devel@gmail.com>
Wed, 13 Oct 2021 03:11:25 +0000 (21:11 -0600)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:13 +0000 (17:09 -0400)
Prevent false positives in bch2_varint_decode_fast()

Signed-off-by: Brett Holman <bholman.devel@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/varint.c

index e87da470c5812bae567fb3b6a25e6c4f2862d70a..5143b603bf67ff397181e70a9705cfa100237fbf 100644 (file)
@@ -5,6 +5,10 @@
 #include <linux/string.h>
 #include <asm/unaligned.h>
 
+#ifdef CONFIG_VALGRIND
+#include <valgrind/memcheck.h>
+#endif
+
 #include "varint.h"
 
 /**
@@ -96,6 +100,9 @@ int bch2_varint_encode_fast(u8 *out, u64 v)
  */
 int bch2_varint_decode_fast(const u8 *in, const u8 *end, u64 *out)
 {
+#ifdef CONFIG_VALGRIND
+       VALGRIND_MAKE_MEM_DEFINED(in, 8);
+#endif
        u64 v = get_unaligned_le64(in);
        unsigned bytes = ffz(*in) + 1;