Skip to content

Commit a1193de

Browse files
surenbaghdasaryanakpm00
authored andcommitted
mm: fix vma->anon_name memory leak for anonymous shmem VMAs
free_anon_vma_name() is missing a check for anonymous shmem VMA which leads to a memory leak due to refcount not being dropped. Fix this by calling anon_vma_name_put() unconditionally. It will free vma->anon_name whenever it's non-NULL. Link: https://lkml.kernel.org/r/[email protected] Fixes: d09e8ca ("mm: anonymous shared memory naming") Signed-off-by: Suren Baghdasaryan <[email protected]> Suggested-by: David Hildenbrand <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Reported-by: [email protected] Cc: Hugh Dickins <[email protected]> Cc: Pasha Tatashin <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 3de0c26 commit a1193de

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

include/linux/mm_inline.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,7 @@ static inline void free_anon_vma_name(struct vm_area_struct *vma)
413413
* Not using anon_vma_name because it generates a warning if mmap_lock
414414
* is not held, which might be the case here.
415415
*/
416-
if (!vma->vm_file)
417-
anon_vma_name_put(vma->anon_name);
416+
anon_vma_name_put(vma->anon_name);
418417
}
419418

420419
static inline bool anon_vma_name_eq(struct anon_vma_name *anon_name1,

0 commit comments

Comments
 (0)