]> git.dujemihanovic.xyz Git - linux.git/commitdiff
mmap: add clarifying comment to vma_merge() code
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Fri, 29 Sep 2023 18:30:41 +0000 (14:30 -0400)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 18 Oct 2023 21:34:15 +0000 (14:34 -0700)
When tracing through the code in vma_merge(), it was not completely
clear why the error return to a dup_anon_vma() call would not overwrite
a previous attempt to the same function.  This commit adds a comment
specifying why it is safe.

Link: https://lkml.kernel.org/r/20230929183041.2835469-4-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Suggested-by: Jann Horn <jannh@google.com>
Link: https://lore.kernel.org/linux-mm/CAG48ez3iDwFPR=Ed1BfrNuyUJPMK_=StjxhUsCkL6po1s7bONg@mail.gmail.com/
Reviewed-by: Lorenzo Stoakes <lstoakes@gmail.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/mmap.c

index 011ba48d9e7247c0b61c22c6c2744b5028e2c624..673429ee8a9e6ec4777b41100127f15dd49d8d36 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -943,6 +943,11 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm,
                        vma_start_write(curr);
                        remove = curr;
                        remove2 = next;
+                       /*
+                        * Note that the dup_anon_vma below cannot overwrite err
+                        * since the first caller would do nothing unless next
+                        * has an anon_vma.
+                        */
                        if (!next->anon_vma)
                                err = dup_anon_vma(prev, curr, &anon_dup);
                }