diff --git a/mm/madvise.c b/mm/madvise.c index 242a88ae3acf1bc7c59188af39cf113f9ca13f8b..6022627646fa2c288f8b68308ff3184e20e9f4d9 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -638,7 +638,6 @@ static long madvise_remove(struct vm_area_struct *vma, static int madvise_inject_error(int behavior, unsigned long start, unsigned long end) { - struct page *page; struct zone *zone; unsigned int order; @@ -647,6 +646,7 @@ static int madvise_inject_error(int behavior, for (; start < end; start += PAGE_SIZE << order) { + struct page *page; unsigned long pfn; int ret; @@ -669,25 +669,23 @@ static int madvise_inject_error(int behavior, if (behavior == MADV_SOFT_OFFLINE) { pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n", - pfn, start); + pfn, start); ret = soft_offline_page(page, MF_COUNT_INCREASED); - if (ret) - return ret; - continue; + } else { + pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n", + pfn, start); + /* + * Drop the page reference taken by + * get_user_pages_fast(). In the absence of + * MF_COUNT_INCREASED the memory_failure() routine is + * responsible for pinning the page to prevent it + * from being released back to the page allocator. + */ + put_page(page); + ret = memory_failure(pfn, 0); } - pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n", - pfn, start); - - /* - * Drop the page reference taken by get_user_pages_fast(). In - * the absence of MF_COUNT_INCREASED the memory_failure() - * routine is responsible for pinning the page to prevent it - * from being released back to the page allocator. - */ - put_page(page); - ret = memory_failure(pfn, 0); if (ret) return ret; }