else
                len = PAGE_SIZE;
 
+       /* Should never happen but for bugs in other kernel subsystems */
+       if (!page_has_buffers(page)) {
+               ext4_warning_inode(inode,
+                  "page %lu does not have buffers attached", page->index);
+               ClearPageDirty(page);
+               unlock_page(page);
+               return 0;
+       }
+
        page_bufs = page_buffers(page);
        /*
         * We cannot do block allocation or other extent handling in this
                        wait_on_page_writeback(page);
                        BUG_ON(PageWriteback(page));
 
+                       /*
+                        * Should never happen but for buggy code in
+                        * other subsystems that call
+                        * set_page_dirty() without properly warning
+                        * the file system first.  See [1] for more
+                        * information.
+                        *
+                        * [1] https://lore.kernel.org/linux-mm/20180103100430.GE4911@quack2.suse.cz
+                        */
+                       if (!page_has_buffers(page)) {
+                               ext4_warning_inode(mpd->inode, "page %lu does not have buffers attached", page->index);
+                               ClearPageDirty(page);
+                               unlock_page(page);
+                               continue;
+                       }
+
                        if (mpd->map.m_len == 0)
                                mpd->first_page = page->index;
                        mpd->next_page = page->index + 1;