linux/arch/powerpc
Vaibhav Jain 0e0946e22f powerpc/papr_scm: Fix leaking nvdimm_events_map elements
Right now 'char *' elements allocated for individual 'stat_id' in
'papr_scm_priv.nvdimm_events_map[]' during papr_scm_pmu_check_events(), get
leaked in papr_scm_remove() and papr_scm_pmu_register(),
papr_scm_pmu_check_events() error paths.

Also individual 'stat_id' arent NULL terminated 'char *' instead they are fixed
8-byte sized identifiers. However papr_scm_pmu_register() assumes it to be a
NULL terminated 'char *' and at other places it assumes it to be a
'papr_scm_perf_stat.stat_id' sized string which is 8-byes in size.

Fix this by allocating the memory for papr_scm_priv.nvdimm_events_map to also
include space for 'stat_id' entries. This is possible since number of available
events/stat_ids are known upfront. This saves some memory and one extra level of
indirection from 'nvdimm_events_map' to 'stat_id'. Also rest of the code
can continue to call 'kfree(papr_scm_priv.nvdimm_events_map)' without needing to
iterate over the array and free up individual elements.

Fixes: 4c08d4bbc0 ("powerpc/papr_scm: Add perf interface support")
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220511082637.646714-1-vaibhav@linux.ibm.com
2022-05-22 15:58:31 +10:00
..
boot powerpc/85xx/p2020: Add fsl,mpc8548-pmc node 2022-05-22 15:58:28 +10:00
configs arch: Remove references to CONFIG_NFSD_V3 in the default configs 2022-03-11 10:25:16 -05:00
crypto powerpc: fix typos in comments 2022-05-05 22:12:44 +10:00
include powerpc/numa: Associate numa node to its cpu earlier 2022-05-22 15:58:30 +10:00
kernel powerpc: Book3S 64-bit outline-only KASAN support 2022-05-22 15:58:29 +10:00
kexec powerpc/kasan: Disable address sanitization in kexec paths 2022-05-22 15:58:29 +10:00
kvm powerpc: Book3S 64-bit outline-only KASAN support 2022-05-22 15:58:29 +10:00
lib powerpc/kasan: Don't instrument non-maskable or raw interrupts 2022-05-22 15:58:29 +10:00
math-emu powerpc/64s: avoid reloading (H)SRR registers if they are still valid 2021-06-25 00:06:55 +10:00
mm powerpc/numa: Associate numa node to its cpu earlier 2022-05-22 15:58:30 +10:00
net powerpc/inst: Remove PPC_INST_BL 2022-05-22 15:58:27 +10:00
perf powerpc/perf: Fix the threshold compare group constraint for power9 2022-05-22 15:58:30 +10:00
platforms powerpc/papr_scm: Fix leaking nvdimm_events_map elements 2022-05-22 15:58:31 +10:00
purgatory powerpc/kexec: Don't use .machine ppc64 in trampoline_64.S 2021-04-08 21:17:43 +10:00
sysdev powerpc/fsl_rio: Fix refcount leak in fsl_rio_setup 2022-05-22 15:58:31 +10:00
tools powerpc/64: Add UADDR64 relocation support 2022-03-09 21:47:53 +11:00
xmon powerpc: Remove asm/prom.h from all files that don't need it 2022-05-08 22:15:04 +10:00
Kbuild kbuild: use more subdir- for visiting subdirectories while cleaning 2021-10-24 13:49:46 +09:00
Kconfig powerpc: Book3S 64-bit outline-only KASAN support 2022-05-22 15:58:29 +10:00
Kconfig.debug powerpc: Book3S 64-bit outline-only KASAN support 2022-05-22 15:58:29 +10:00
Makefile powerpc: Finalise cleanup around ABI use 2022-05-19 23:11:29 +10:00
Makefile.postlink powerpc: unrel_branch_check.sh: use nm to find symbol value 2020-09-02 11:00:22 +10:00