From 81a070730e602042e2f38ad68c2922d4e1a50920 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Wed, 15 Oct 2003 17:31:16 -0700 Subject: [PATCH] [PATCH] Don't swap to files which do not implement readpage From: Zwane Mwaikambo The swapon code uses read_cache_page() to access the swap header, so the filesystem had better implement it. --- mm/swapfile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/swapfile.c b/mm/swapfile.c index 8d252bdb4db37..6c23241ad9b3d 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1318,6 +1318,10 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags) /* * Read the swap header. */ + if (!mapping->a_ops->readpage) { + error = -EINVAL; + goto bad_swap; + } page = read_cache_page(mapping, 0, (filler_t *)mapping->a_ops->readpage, swap_file); if (IS_ERR(page)) { -- 2.53.0