From: Kirill A. Shutemov Date: Wed, 21 Oct 2015 22:03:45 +0000 (+1100) Subject: mm, madvise: use vma_is_anonymous() to check for anon VMA X-Git-Tag: KARO-TX6UL-2015-11-03~14^2~88 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=a550e2f5c3a3800889a28fe0a56d6bd9e73fd81d;p=karo-tx-linux.git mm, madvise: use vma_is_anonymous() to check for anon VMA !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 Acked-by: Minchan Kim Reviewed-by: Oleg Nesterov Cc: "H. Peter Anvin" Cc: Andy Lutomirski Cc: Dave Hansen Cc: Ingo Molnar Cc: Thomas Gleixner Signed-off-by: Andrew Morton --- diff --git a/mm/madvise.c b/mm/madvise.c index 38a54267342e..84c29e51e765 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -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);