Skip to content

Commit b1b4675

Browse files
committed
mm: fix follow_pfnmap API lockdep assert
The lockdep asserts for the new follow_pfnmap() API "knows" that a pfnmap always has a vma->vm_file, since that's the only way to create such a mapping. And that's actually true for all the normal cases. But not for the mmap failure case, where the incomplete mapping is torn down and we have cleared vma->vm_file because the failure occured before the file was linked to the vma. So this codepath does actually need to check for vm_file being NULL. Reported-by: Jann Horn <[email protected]> Fixes: 6da8e96 ("mm: new follow_pfnmap API") Cc: Peter Xu <[email protected]> Cc: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 75aa74d commit b1b4675

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mm/memory.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6350,7 +6350,8 @@ static inline void pfnmap_args_setup(struct follow_pfnmap_args *args,
63506350
static inline void pfnmap_lockdep_assert(struct vm_area_struct *vma)
63516351
{
63526352
#ifdef CONFIG_LOCKDEP
6353-
struct address_space *mapping = vma->vm_file->f_mapping;
6353+
struct file *file = vma->vm_file;
6354+
struct address_space *mapping = file ? file->f_mapping : NULL;
63546355

63556356
if (mapping)
63566357
lockdep_assert(lockdep_is_held(&vma->vm_file->f_mapping->i_mmap_rwsem) ||

0 commit comments

Comments
 (0)