nommu: Fix memory leak in do_mmap() error path
Subsystems (3)
PATCH v2 1/1 nommu: Fix memory leak in do_mmap() error path
The preallocation of the maple tree nodes may leak if the error path to "error_just_free" is taken. Fix this by moving the freeing of the maple tree nodes to a shared location for all error paths.
Fixes 8220543df148 ("nommu: remove uses of VMA linked list")
Signed-off-by Liam R. Howlett <[email protected]>
---
Changes since v1:
- Added 'Cc: [email protected]' to commit message
mm/nommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/nommu.c +1 -1
@@ -1240,6 +1240,7 @@ unsigned long do_mmap(struct file *file, error_just_free:up_write (&nommu_region_sem); error: +mas_destroy (&mas);if (region->vm_file)fput (region->vm_file);kmem_cache_free (vm_region_jar, region);
@@ -1250,7 +1251,6 @@ unsigned long do_mmap(struct file *file, sharing_violation:up_write (&nommu_region_sem); -mas_destroy (&mas);pr_warn ("Attempt to share mismatched mappings\n" ); ret = -EINVAL ; goto error;
Signature · 1 line
2.35.1