diff options
| author | Miaoqian Lin <[email protected]> | 2025-10-27 15:08:38 +0000 |
|---|---|---|
| committer | Heiko Carstens <[email protected]> | 2025-10-29 13:17:50 +0000 |
| commit | 07ad45e06b4039adf96882aefcb1d3299fb7c305 (patch) | |
| tree | b5745a57ebc502d54cf608fd421939f720f2b090 /lib/mpi/mpi-mod.c | |
| parent | s390/pci: Restore IRQ unconditionally for the zPCI device (diff) | |
| download | kernel-07ad45e06b4039adf96882aefcb1d3299fb7c305.tar.gz kernel-07ad45e06b4039adf96882aefcb1d3299fb7c305.zip | |
s390/mm: Fix memory leak in add_marker() when kvrealloc() fails
The function has a memory leak when kvrealloc() fails.
The function directly assigns NULL to the markers pointer, losing the
reference to the previously allocated memory. This causes kvfree() in
pt_dump_init() to free NULL instead of the leaked memory.
Fix by:
1. Using kvrealloc() uniformly for all allocations
2. Using a temporary variable to preserve the original pointer until
allocation succeeds
3. Removing the error path that sets markers_cnt=0 to keep
consistency between markers and markers_cnt
Found via static analysis and this is similar to commit 42378a9ca553
("bpf, verifier: Fix memory leak in array reallocation for stack state")
Fixes: d0e7915d2ad3 ("s390/mm/ptdump: Generate address marker array dynamically")
Cc: [email protected]
Signed-off-by: Miaoqian Lin <[email protected]>
Signed-off-by: Heiko Carstens <[email protected]>
Diffstat (limited to 'lib/mpi/mpi-mod.c')
0 files changed, 0 insertions, 0 deletions
