summaryrefslogtreecommitdiff
path: root/fs/bcachefs/io.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-10-13 13:45:46 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:13 -0400
commitedeb986b017e9489add4daa7e61bc79cdbfb913c (patch)
treee83472df96bab8579fda0f75e3b0eade5e234eb0 /fs/bcachefs/io.c
parentb9a7d8ac5f6d66619de8a4e37b23574d1ca107cf (diff)
downloadlwn-edeb986b017e9489add4daa7e61bc79cdbfb913c.tar.gz
lwn-edeb986b017e9489add4daa7e61bc79cdbfb913c.zip
bcachefs: Don't allocate too-big bios
This fixes a null ptr deref in bio_alloc_bioset() -> biovec_slab() Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/io.c')
-rw-r--r--fs/bcachefs/io.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c
index 002fd35e6bfe..ea2adcc213d0 100644
--- a/fs/bcachefs/io.c
+++ b/fs/bcachefs/io.c
@@ -782,6 +782,8 @@ static struct bio *bch2_write_bio_alloc(struct bch_fs *c,
? ((unsigned long) buf & (PAGE_SIZE - 1))
: 0), PAGE_SIZE);
+ pages = min(pages, BIO_MAX_VECS);
+
bio = bio_alloc_bioset(NULL, pages, 0,
GFP_NOIO, &c->bio_write);
wbio = wbio_init(bio);