Skip to contentSkip to conversation

arm: fix valid_phys_addr_range() range check

PATCH New Greg Ungerer 2 participants 3 messages Sep 24, 2009 – Oct 2, 2009 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: fix valid_phys_addr_range() range check

arm: fix valid_phys_addr_range() range check

Commit 1522ac3ec95ff0230e7aa516f86b674fdf72866c ("Fix virtual to physical translation macro corner cases") breaks the end of memory check in valid_phys_addr_range(). The modified expression results in the apparent /dev/mem size being 2 bytes smaller than what it actually is.

This patch reworks the expression to correctly check the address, while maintaining use of a valid address to __pa().

---
 arch/arm/mm/mmap.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/mm/mmap.c +1 -1
index f7457fe..2b79964 100644
@@ -124,7 +124,7 @@ int valid_phys_addr_range(unsigned long addr, size_t size)
 {
 	if (addr < PHYS_OFFSET)
 		return 0;
-	if (addr + size >= __pa(high_memory - 1))
+	if (addr + size > __pa(high_memory - 1) + 1)
 		return 0;
 
 	return 1;
Signature · 1 line
1.5.5.1
#1 lore raw

PATCH 1/1 arm: fix valid_phys_addr_range() range check

Quoted 10 lines · Greg Ungerer

arm: fix valid_phys_addr_range() range check

Commit 1522ac3ec95ff0230e7aa516f86b674fdf72866c ("Fix virtual to physical translation macro corner cases") breaks the end of memory check in valid_phys_addr_range(). The modified expression results in the apparent /dev/mem size being 2 bytes smaller than what it actually is.

This patch reworks the expression to correctly check the address, while maintaining use of a valid address to __pa().

Looks good, can you please send it to the patch system?

#2 lore raw

PATCH 1/1 arm: fix valid_phys_addr_range() range check

Hi Russell,

Quoted 9 lines · Russell King - ARM Linux
Quoted 8 lines · Greg Ungerer

arm: fix valid_phys_addr_range() range check

Commit 1522ac3ec95ff0230e7aa516f86b674fdf72866c ("Fix virtual to physical translation macro corner cases") breaks the end of memory check in valid_phys_addr_range(). The modified expression results in the apparent /dev/mem size being 2 bytes smaller than what it actually is.

Quoted 4 lines
Quoted 2 lines

This patch reworks the expression to correctly check the address, while maintaining use of a valid address to __pa().

Looks good, can you please send it to the patch system?

Done, patch 5740/1.

Thanks
Greg

------------------------------------------------------------------------

Greg Ungerer  --  Principal Engineer        EMAIL:     gerg at snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
825 Stanley St,                             FAX:         +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia         WEB: http://www.SnapGear.com