summaryrefslogtreecommitdiff
path: root/fs/bcachefs/printbuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/bcachefs/printbuf.c')
-rw-r--r--fs/bcachefs/printbuf.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/bcachefs/printbuf.c b/fs/bcachefs/printbuf.c
index 8b0369185f5c..9f529e4c1b16 100644
--- a/fs/bcachefs/printbuf.c
+++ b/fs/bcachefs/printbuf.c
@@ -45,6 +45,13 @@ int bch2_printbuf_make_room(struct printbuf *out, unsigned extra)
unsigned new_size = roundup_pow_of_two(out->size + extra);
+ /* Sanity check... */
+ if (new_size > PAGE_SIZE << MAX_PAGE_ORDER) {
+ out->allocation_failure = true;
+ out->overflow = true;
+ return -ENOMEM;
+ }
+
/*
* Note: output buffer must be freeable with kfree(), it's not required
* that the user use printbuf_exit().