View | Details | Raw Unified | Return to bug 84728
Collapse All | Expand All

(-)file_not_specified_in_diff (-31 / +36 lines)
Line  Link Here
0
-- a/include/linux/err.h
0
++ b/include/linux/err.h
Lines 13-18 Link Here
13
 * This should be a per-architecture thing, to allow different
13
 * This should be a per-architecture thing, to allow different
14
 * error and pointer decisions.
14
 * error and pointer decisions.
15
 */
15
 */
16
#define IS_ERR_VALUE(x) unlikely((x) > (unsigned long)-1000L)
17
16
static inline void *ERR_PTR(long error)
18
static inline void *ERR_PTR(long error)
17
{
19
{
18
	return (void *) error;
20
	return (void *) error;
Lines 25-31 static inline long PTR_ERR(const void *p Link Here
25
27
26
static inline long IS_ERR(const void *ptr)
28
static inline long IS_ERR(const void *ptr)
27
{
29
{
28
	return unlikely((unsigned long)ptr > (unsigned long)-1000L);
30
	return IS_ERR_VALUE((unsigned long)ptr);
29
}
31
}
30
32
31
#endif /* _LINUX_ERR_H */
33
#endif /* _LINUX_ERR_H */
32
-- a/mm/mmap.c
34
++ b/mm/mmap.c
Lines 1315-1351 unsigned long Link Here
1315
get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
1315
get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
1316
		unsigned long pgoff, unsigned long flags)
1316
		unsigned long pgoff, unsigned long flags)
1317
{
1317
{
1318
	if (flags & MAP_FIXED) {
1318
	unsigned long ret;
1319
		unsigned long ret;
1320
1319
1321
		if (addr > TASK_SIZE - len)
1320
	if (!(flags & MAP_FIXED)) {
1322
			return -ENOMEM;
1321
		unsigned long (*get_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
1323
		if (addr & ~PAGE_MASK)
1324
			return -EINVAL;
1325
		if (file && is_file_hugepages(file))  {
1326
			/*
1327
			 * Check if the given range is hugepage aligned, and
1328
			 * can be made suitable for hugepages.
1329
			 */
1330
			ret = prepare_hugepage_range(addr, len);
1331
		} else {
1332
			/*
1333
			 * Ensure that a normal request is not falling in a
1334
			 * reserved hugepage range.  For some archs like IA-64,
1335
			 * there is a separate region for hugepages.
1336
			 */
1337
			ret = is_hugepage_only_range(addr, len);
1338
		}
1339
		if (ret)
1340
			return -EINVAL;
1341
		return addr;
1342
	}
1343
1322
1344
	if (file && file->f_op && file->f_op->get_unmapped_area)
1323
		get_area = current->mm->get_unmapped_area;
1345
		return file->f_op->get_unmapped_area(file, addr, len,
1324
		if (file && file->f_op && file->f_op->get_unmapped_area)
1346
						pgoff, flags);
1325
			get_area = file->f_op->get_unmapped_area;
1326
		addr = get_area(file, addr, len, pgoff, flags);
1327
		if (IS_ERR_VALUE(addr))
1328
			return addr;
1329
	}
1347
1330
1348
	return current->mm->get_unmapped_area(file, addr, len, pgoff, flags);
1331
	if (addr > TASK_SIZE - len)
1332
		return -ENOMEM;
1333
	if (addr & ~PAGE_MASK)
1334
		return -EINVAL;
1335
	if (file && is_file_hugepages(file))  {
1336
		/*
1337
		 * Check if the given range is hugepage aligned, and
1338
		 * can be made suitable for hugepages.
1339
		 */
1340
		ret = prepare_hugepage_range(addr, len);
1341
	} else {
1342
		/*
1343
		 * Ensure that a normal request is not falling in a
1344
		 * reserved hugepage range.  For some archs like IA-64,
1345
		 * there is a separate region for hugepages.
1346
		 */
1347
		ret = is_hugepage_only_range(addr, len);
1348
	}
1349
	if (ret)
1350
		return -EINVAL;
1351
	return addr;
1349
}
1352
}
1350
1353
1351
EXPORT_SYMBOL(get_unmapped_area);
1354
EXPORT_SYMBOL(get_unmapped_area);

Return to bug 84728