Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e2779fa authored by Christoph Lameter's avatar Christoph Lameter Committed by Linus Torvalds
Browse files

is_vmalloc_addr(): Check if an address is within the vmalloc boundaries



Checking if an address is a vmalloc address is done in a couple of places.
Define a common version in mm.h and replace the other checks.

Again the include structures suck.  The definition of VMALLOC_START and
VMALLOC_END is not available in vmalloc.h since highmem.c cannot be included
there.

Signed-off-by: default avatarChristoph Lameter <clameter@sgi.com>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0b7a9611
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -1070,9 +1070,7 @@ void *cxgb_alloc_mem(unsigned long size)
 */
void cxgb_free_mem(void *addr)
{
	unsigned long p = (unsigned long)addr;

	if (p >= VMALLOC_START && p < VMALLOC_END)
	if (is_vmalloc_addr(addr))
		vfree(addr);
	else
		kfree(addr);
+1 −2
Original line number Diff line number Diff line
@@ -85,8 +85,7 @@ static inline void *ntfs_malloc_nofs_nofail(unsigned long size)

static inline void ntfs_free(void *addr)
{
	if (likely(((unsigned long)addr < VMALLOC_START) ||
			((unsigned long)addr >= VMALLOC_END ))) {
	if (!is_vmalloc_addr(addr)) {
		kfree(addr);
		/* free_page((unsigned long)addr); */
		return;
+1 −1
Original line number Diff line number Diff line
@@ -325,7 +325,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
		if (m == NULL) {
			if (clear_user(buffer, tsz))
				return -EFAULT;
		} else if ((start >= VMALLOC_START) && (start < VMALLOC_END)) {
		} else if (is_vmalloc_addr((void *)start)) {
			char * elf_buf;
			struct vm_struct *m;
			unsigned long curstart = start;
+1 −2
Original line number Diff line number Diff line
@@ -92,8 +92,7 @@ kmem_zalloc_greedy(size_t *size, size_t minsize, size_t maxsize,
void
kmem_free(void *ptr, size_t size)
{
	if (((unsigned long)ptr < VMALLOC_START) ||
	    ((unsigned long)ptr >= VMALLOC_END)) {
	if (!is_vmalloc_addr(ptr)) {
		kfree(ptr);
	} else {
		vfree(ptr);
+1 −2
Original line number Diff line number Diff line
@@ -709,8 +709,7 @@ static inline struct page *
mem_to_page(
	void			*addr)
{
	if (((unsigned long)addr < VMALLOC_START) ||
	    ((unsigned long)addr >= VMALLOC_END)) {
	if ((!is_vmalloc_addr(addr))) {
		return virt_to_page(addr);
	} else {
		return vmalloc_to_page(addr);
Loading