linux/arch
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
..
alpha alpha: remove CONFIG_EXPERIMENTAL from defconfigs 2021-02-26 09:41:03 -08:00
arc arch: arc: Remove CONFIG_OPROFILE support 2021-01-22 12:12:03 +05:30
arm Kbuild updates for v5.12 2021-02-25 10:17:31 -08:00
arm64 arm64: kasan: simplify and inline MTE functions 2021-02-26 09:41:03 -08:00
csky
h8300 h8300: fix PREEMPTION build, TI_PRE_COUNT undefined 2021-02-13 11:42:40 -08:00
hexagon hexagon: remove CONFIG_EXPERIMENTAL from defconfigs 2021-02-24 13:38:26 -08:00
ia64 Kbuild updates for v5.12 2021-02-25 10:17:31 -08:00
m68k Kbuild updates for v5.12 2021-02-25 10:17:31 -08:00
microblaze Kbuild updates for v5.12 2021-02-25 10:17:31 -08:00
mips Kbuild updates for v5.12 2021-02-25 10:17:31 -08:00
nds32 nds32: Fix bogus reference to <asm/procinfo.h> 2021-02-25 14:31:49 +08:00
nios2 nios2: Don't use _end for calculating min_low_pfn 2021-02-19 15:02:09 +08:00
openrisc
parisc Kbuild updates for v5.12 2021-02-25 10:17:31 -08:00
powerpc Kbuild updates for v5.12 2021-02-25 10:17:31 -08:00
riscv Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2021-02-20 17:45:32 -08:00
s390 s390/mm: define arch_get_mappable_range() 2021-02-26 09:41:01 -08:00
sh Kbuild updates for v5.12 2021-02-25 10:17:31 -08:00
sparc Kbuild updates for v5.12 2021-02-25 10:17:31 -08:00
um Rework of the X86 irq stack handling: 2021-02-24 16:32:23 -08:00
x86 x86: fix seq_file iteration for pat/memtype.c 2021-02-26 09:41:05 -08:00
xtensa Kbuild updates for v5.12 2021-02-25 10:17:31 -08:00
.gitignore
Kconfig Rework of the X86 irq stack handling: 2021-02-24 16:32:23 -08:00