From: Hugh Dickins Date: Fri, 29 Sep 2006 09:01:26 +0000 (-0700) Subject: [PATCH] valid_swaphandles() fix X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3f9e7949f86dfe2bd9a1ad0604f78e7683c059de;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [PATCH] valid_swaphandles() fix akpm draws my attention to the fact that sysctl(VM_PAGE_CLUSTER) might conceivably change page_cluster to 0 while valid_swaphandles() is in the middle of using it, leading to an embarrassingly long loop: take a local snapshot of page_cluster and work with that. Signed-off-by: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/swapfile.c b/mm/swapfile.c index f1f5ec783781..a15def63f28f 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1723,13 +1723,14 @@ get_swap_info_struct(unsigned type) */ int valid_swaphandles(swp_entry_t entry, unsigned long *offset) { - int ret = 0, i = 1 << page_cluster; + int our_page_cluster = page_cluster; + int ret = 0, i = 1 << our_page_cluster; unsigned long toff; struct swap_info_struct *swapdev = swp_type(entry) + swap_info; - if (!page_cluster) /* no readahead */ + if (!our_page_cluster) /* no readahead */ return 0; - toff = (swp_offset(entry) >> page_cluster) << page_cluster; + toff = (swp_offset(entry) >> our_page_cluster) << our_page_cluster; if (!toff) /* first page is swap header */ toff++, i--; *offset = toff;