Skip to contentSkip to conversation

mm/mmap.c: remove redundant check "if (length < info->length)"

PATCH Naoya Horiguchi 1 participant 1 message Jan 8, 2016 1 message not in the archive Memory management

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 8 lines · Wang Xiaoqiang

Hi, all,

since the code:

length = info->length + info->align_mask

and all variables above are "unsigned long" type,
so there must be "length >= info->length".

I think that if info->align_mask is "very large" as an unsigned long value and the sum of these 2 overflows, length can become smaller than info->length, so we seem to need the check.

But why returning -ENOMEM? Isn't it worth VM_BUG_ON()?

Thanks,
Naoya Horiguchi

Quoted 26 lines
---
 mm/mmap.c | 2 --
 1 file changed, 2 deletions(-)
mm/mmap.c +0 -2
index 2ce04a6..99fc461 100644
@@ -1716,8 +1716,6 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
 
 	/* Adjust search length to account for worst case alignment overhead */
 	length = info->length + info->align_mask;
-	if (length < info->length)
-		return -ENOMEM;
 
 	/* Adjust search limits by the desired length */
 	if (info->high_limit < length)
Signature · 4 lines
2.1.4

thanks,
Wang Xiaoqiang

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>