mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC] ARC: mm: Restrict definition of pfn_valid() macro for CONFIG_FLATMEM
@ 2016-11-29 15:29 Yuriy Kolerov
  2016-11-30  9:16 ` Michal Hocko
  0 siblings, 1 reply; 5+ messages in thread
From: Yuriy Kolerov @ 2016-11-29 15:29 UTC (permalink / raw)
  To: linux-snps-arc; +Cc: Vineet.Gupta1, Alexey.Brodkin, linux-kernel, Yuriy Kolerov

Despite the fact that subtraction of unsigned integers is a defined
behaviour however such operations can lead to unexpected results. Thus
it is better to check both left and right boundaries to avoid potential
bugs as it done in the generic page.h.

Signed-off-by: Yuriy Kolerov <yuriy.kolerov@synopsys.com>
---
 arch/arc/include/asm/page.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arc/include/asm/page.h b/arch/arc/include/asm/page.h
index 296c342..81cfc6c7 100644
--- a/arch/arc/include/asm/page.h
+++ b/arch/arc/include/asm/page.h
@@ -88,7 +88,7 @@ typedef pte_t * pgtable_t;
 #define ARCH_PFN_OFFSET		virt_to_pfn(CONFIG_LINUX_LINK_BASE)
 
 #ifdef CONFIG_FLATMEM
-#define pfn_valid(pfn)		(((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
+#define pfn_valid(pfn)		((pfn) >= ARCH_PFN_OFFSET && ((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
 #endif
 
 /*
-- 
2.7.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-12-02 14:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-29 15:29 [RFC] ARC: mm: Restrict definition of pfn_valid() macro for CONFIG_FLATMEM Yuriy Kolerov
2016-11-30  9:16 ` Michal Hocko
2016-11-30 14:21   ` Yuriy Kolerov
2016-11-30 16:55     ` Vineet Gupta
2016-12-02 14:14       ` Yuriy Kolerov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome