]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm/mmap/vma_merge: explicitly assign res, vma, extend invariants
authorLorenzo Stoakes <lstoakes@gmail.com>
Wed, 22 Mar 2023 20:18:59 +0000 (20:18 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 28 Mar 2023 23:25:15 +0000 (16:25 -0700)
commite39c6376b213d288b281a22694938c50bed35bab
tree38244382847f9ec16cd3761b2dc69696b0e44ace
parent75c0158d855a9b82899dbe06c957e986bc38548a
mm/mmap/vma_merge: explicitly assign res, vma, extend invariants

Previously, vma was an uninitialised variable which was only definitely
assigned as a result of the logic covering all possible input cases - for
it to have remained uninitialised, prev would have to be NULL, and next
would _have_ to be mergeable.

The value of res defaults to NULL, so we can neatly eliminate the
assignment to res and vma in the if (prev) block and ensure that both res
and vma are both explicitly assigned, by just setting both to prev.

In addition we add an explanation as to under what circumstances both
might change, and since we absolutely do rely on addr == curr->vm_start
should curr exist, assert that this is the case.

Link: https://lkml.kernel.org/r/83938bed24422cbe5954bbf491341674becfe567.1679516210.git.lstoakes@gmail.com
Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Vernon Yang <vernon2gm@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/mmap.c