Skip to content

Commit 6fcac87

Browse files
QiuXitorvalds
authored andcommitted
coredump: fix memleak in dump_vma_snapshot()
dump_vma_snapshot() allocs memory for *vma_meta, when dump_vma_snapshot() returns -EFAULT, the memory will be leaked, so we free it correctly. Link: https://lkml.kernel.org/r/[email protected] Fixes: a07279c ("binfmt_elf, binfmt_elf_fdpic: use a VMA list snapshot") Signed-off-by: QiuXi <[email protected]> Cc: Al Viro <[email protected]> Cc: Jann Horn <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent dbd9d6f commit 6fcac87

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/coredump.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,8 +1134,10 @@ int dump_vma_snapshot(struct coredump_params *cprm, int *vma_count,
11341134

11351135
mmap_write_unlock(mm);
11361136

1137-
if (WARN_ON(i != *vma_count))
1137+
if (WARN_ON(i != *vma_count)) {
1138+
kvfree(*vma_meta);
11381139
return -EFAULT;
1140+
}
11391141

11401142
*vma_data_size_ptr = vma_data_size;
11411143
return 0;

0 commit comments

Comments
 (0)