===================================================================
@@ -137,6 +137,8 @@ void swap_sync_page(struct page *page)
{
struct swap_info_struct *sis = page_swap_info(page);
+ if (!sis)
+ return;
if (sis->flags & SWP_FILE) {
struct address_space *mapping = sis->swap_file->f_mapping;
===================================================================
@@ -2185,7 +2185,13 @@ get_swap_info_struct(unsigned type)
struct swap_info_struct *page_swap_info(struct page *page)
{
swp_entry_t swap = { .val = page_private(page) };
- BUG_ON(!PageSwapCache(page));
+ if (!PageSwapCache(page) || !swap.val) {
+ /* This should only happen from sync_page.
+ * In other cases the page should be locked and
+ * should be in a SwapCache
+ */
+ return NULL;
+ }
return &swap_info[swp_type(swap)];
}