summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/util.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-03-17 02:22:47 +0100
committerKent Overstreet <kent.overstreet@linux.dev>2024-03-18 02:17:38 +0100
commita58603684195ea892da5612580762fd3151b2a7b (patch)
treec716679279dfab8d1f758e542da8e86c0d5aef96 /fs/bcachefs/util.h
parentbcachefs: fix for building in userspace (diff)
downloadlinux-a58603684195ea892da5612580762fd3151b2a7b.tar.xz
linux-a58603684195ea892da5612580762fd3151b2a7b.zip
bcachefs: Don't corrupt journal keys gap buffer when dropping alloc info
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/util.h')
-rw-r--r--fs/bcachefs/util.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h
index 7ffbddb80400..175aee3074c7 100644
--- a/fs/bcachefs/util.h
+++ b/fs/bcachefs/util.h
@@ -683,6 +683,9 @@ static inline void __move_gap(void *array, size_t element_size,
/* Move the gap in a gap buffer: */
#define move_gap(_d, _new_gap) \
do { \
+ BUG_ON(_new_gap > (_d)->nr); \
+ BUG_ON((_d)->gap > (_d)->nr); \
+ \
__move_gap((_d)->data, sizeof((_d)->data[0]), \
(_d)->nr, (_d)->size, (_d)->gap, _new_gap); \
(_d)->gap = _new_gap; \