[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200305130550.22693-1-steven.price@arm.com>
Date: Thu, 5 Mar 2020 13:05:50 +0000
From: Steven Price <steven.price@....com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Steven Price <steven.price@....com>, linux-kernel@...r.kernel.org,
Jérôme Glisse <jglisse@...hat.com>,
Arnd Bergmann <arnd@...db.de>,
Dan Williams <dan.j.williams@...el.com>
Subject: [PATCH] mm: Correct guards for non_swap_entry()
If CONFIG_DEVICE_PRIVATE is defined, but neither CONFIG_MEMORY_FAILURE nor
CONFIG_MIGRATION, then non_swap_entry() will return 0, meaning that the
condition (non_swap_entry(entry) && is_device_private_entry(entry)) in
zap_pte_range() will never be true even if the entry is a device private
one.
Equally any other code depending on non_swap_entry() will not function
as expected.
Fixes: 5042db43cc26 ("mm/ZONE_DEVICE: new type of ZONE_DEVICE for unaddressable memory")
Signed-off-by: Steven Price <steven.price@....com>
---
include/linux/swapops.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/linux/swapops.h b/include/linux/swapops.h
index 877fd239b6ff..3208a520d0be 100644
--- a/include/linux/swapops.h
+++ b/include/linux/swapops.h
@@ -348,7 +348,8 @@ static inline void num_poisoned_pages_inc(void)
}
#endif
-#if defined(CONFIG_MEMORY_FAILURE) || defined(CONFIG_MIGRATION)
+#if defined(CONFIG_MEMORY_FAILURE) || defined(CONFIG_MIGRATION) || \
+ defined(CONFIG_DEVICE_PRIVATE)
static inline int non_swap_entry(swp_entry_t entry)
{
return swp_type(entry) >= MAX_SWAPFILES;
--
2.20.1
Powered by blists - more mailing lists