diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index a2e69d2..6b0e049 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -535,6 +535,11 @@ static int null_add_dev(void)
if (!nullb)
return -ENOMEM;
+ if (bs > PAGE_SIZE) {
+ WARN(1, "Invalid block size. Setting it to 4096\n");
+ bs = 4096;
+ }
+
spin_lock_init(&nullb->lock);
if (queue_mode == NULL_Q_MQ && use_per_node_hctx)
diff --git a/fs/buffer.c b/fs/buffer.c
index 6024877..029c698 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -883,6 +883,7 @@ struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size,
struct buffer_head *bh, *head;
long offset;
+ BUG_ON(size > PAGE_SIZE);
try_again:
head = NULL;
offset = PAGE_SIZE;
@@ -1571,6 +1572,7 @@ void create_empty_buffers(struct page *page,
struct buffer_head *bh, *head, *tail;
head = alloc_page_buffers(page, blocksize, 1);
+ BUG_ON(!head);
bh = head;
do {
bh->b_state |= b_state;