diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2019-02-27 19:14:23 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:16 -0400 |
commit | 8db2acde2fca80954b4db12977182aa44b1e85fe (patch) | |
tree | 14813240f2719823a946b6bc62a755ae9ea22c01 /fs/bcachefs/journal.c | |
parent | 28062d320bded23eb7d24633e6ab11ea3c03487b (diff) | |
download | lwn-8db2acde2fca80954b4db12977182aa44b1e85fe.tar.gz lwn-8db2acde2fca80954b4db12977182aa44b1e85fe.zip |
bcachefs: fix integer underflow in journal code
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/journal.c')
-rw-r--r-- | fs/bcachefs/journal.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c index 91d0e5d443ed..3a6040244064 100644 --- a/fs/bcachefs/journal.c +++ b/fs/bcachefs/journal.c @@ -256,6 +256,8 @@ static int journal_entry_open(struct journal *j) do { old.v = new.v = v; + EBUG_ON(journal_state_count(new, new.idx)); + if (old.cur_entry_offset == JOURNAL_ENTRY_ERROR_VAL) return -EROFS; @@ -429,7 +431,7 @@ void bch2_journal_entry_res_resize(struct journal *j, if (d <= 0) goto out; - j->cur_entry_u64s -= d; + j->cur_entry_u64s = max_t(int, 0, j->cur_entry_u64s - d); smp_mb(); state = READ_ONCE(j->reservations); |