kernel-hacking-2024-linux-s.../arch/x86/mm
NeilBrown 3d2fc4c082 x86: fix seq_file iteration for pat/memtype.c
The memtype seq_file iterator allocates a buffer in the ->start and ->next
functions and frees it in the ->show function.  The preferred handling for
such resources is to free them in the subsequent ->next or ->stop function
call.

Since Commit 1f4aace60b ("fs/seq_file.c: simplify seq_file iteration
code and interface") there is no guarantee that ->show will be called
after ->next, so this function can now leak memory.

So move the freeing of the buffer to ->next and ->stop.

Link: https://lkml.kernel.org/r/161248539022.21478.13874455485854739066.stgit@noble1
Fixes: 1f4aace60b ("fs/seq_file.c: simplify seq_file iteration code and interface")
Signed-off-by: NeilBrown <neilb@suse.de>
Cc: Xin Long <lucien.xin@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Vlad Yasevich <vyasevich@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-02-26 09:41:05 -08:00
..
pat x86: fix seq_file iteration for pat/memtype.c 2021-02-26 09:41:05 -08:00
amdtopology.c
cpu_entry_area.c
debug_pagetables.c
dump_pagetables.c
extable.c
fault.c kfence: add test suite 2021-02-26 09:41:02 -08:00
highmem_32.c
hugetlbpage.c
ident_map.c
init.c x86/mm: Increase pgt_buf size for 5-level page tables 2021-01-04 18:07:50 +01:00
init_32.c
init_64.c
iomap_32.c
ioremap.c
kasan_init_64.c
kaslr.c
kmmio.c
maccess.c
Makefile
mem_encrypt.c Do not unroll string I/O for SEV-ES guests because they support it. 2021-02-20 19:16:02 -08:00
mem_encrypt_boot.S
mem_encrypt_identity.c
mm_internal.h
mmap.c
mmio-mod.c x86: Remove definition of DEBUG 2021-01-15 08:23:10 +01:00
numa.c
numa_32.c
numa_64.c
numa_emulation.c
numa_internal.h
pf_in.c
pf_in.h
pgtable.c x86/mm: Fix leak of pmd ptlock 2021-01-05 11:40:23 +01:00
pgtable_32.c
physaddr.c
physaddr.h
pkeys.c
pti.c
setup_nx.c
srat.c
testmmiotrace.c
tlb.c