diff options
| author | Thomas Gleixner <tglx@linutronix.de> | 2010-04-13 14:12:17 +0200 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2010-04-13 14:12:17 +0200 |
| commit | 7c7145f6acc68100dbdc5d3c5c64fe3af1c99c89 (patch) | |
| tree | 5e93e3eb4787229032f1df222fa490112f4b0c32 /mm/util.c | |
| parent | 92d6b71ab906be706f3679353b30a8d2c3831144 (diff) | |
| parent | 0d0fb0f9c5fddef4a10242fe3337f00f528a3099 (diff) | |
| download | olio-linux-3.10-7c7145f6acc68100dbdc5d3c5c64fe3af1c99c89.tar.xz olio-linux-3.10-7c7145f6acc68100dbdc5d3c5c64fe3af1c99c89.zip | |
Merge branch 'linus' into irq/core
Reason: Get the upstream IRQF_DISABLED related changes.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'mm/util.c')
| -rw-r--r-- | mm/util.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/mm/util.c b/mm/util.c index 834db7be240..f5712e8964b 100644 --- a/mm/util.c +++ b/mm/util.c @@ -186,6 +186,27 @@ void kzfree(const void *p) } EXPORT_SYMBOL(kzfree); +int kern_ptr_validate(const void *ptr, unsigned long size) +{ + unsigned long addr = (unsigned long)ptr; + unsigned long min_addr = PAGE_OFFSET; + unsigned long align_mask = sizeof(void *) - 1; + + if (unlikely(addr < min_addr)) + goto out; + if (unlikely(addr > (unsigned long)high_memory - size)) + goto out; + if (unlikely(addr & align_mask)) + goto out; + if (unlikely(!kern_addr_valid(addr))) + goto out; + if (unlikely(!kern_addr_valid(addr + size - 1))) + goto out; + return 1; +out: + return 0; +} + /* * strndup_user - duplicate an existing string from user space * @s: The string to duplicate |