]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm, madvise: use vma_is_anonymous() to check for anon VMA
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Wed, 21 Oct 2015 22:03:45 +0000 (09:03 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 21 Oct 2015 22:03:45 +0000 (09:03 +1100)
!vma->vm_file is not reliable to detect anon VMA, because not all
drivers bother set it. Let's use vma_is_anonymous() instead.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/madvise.c

index 38a54267342e2d5bb5298f4f7f536a95e0a378b9..84c29e51e76512f7463fe7383c712adce2c34eb5 100644 (file)
@@ -357,7 +357,7 @@ static int madvise_free_single_vma(struct vm_area_struct *vma,
                return -EINVAL;
 
        /* MADV_FREE works for only anon vma at the moment */
-       if (vma->vm_file)
+       if (!vma_is_anonymous(vma))
                return -EINVAL;
 
        start = max(vma->vm_start, start_addr);