linux/fs/pstore
Cole Leavitt 641551ec26 pstore/ram: fix resource leak when ioremap() fails
[ Upstream commit 2ddb69f686 ]

In persistent_ram_iomap(), ioremap() or ioremap_wc() may return NULL on
failure. Currently, if this happens, the function returns NULL without
releasing the memory region acquired by request_mem_region().

This leads to a resource leak where the memory region remains reserved
but unusable.

Additionally, the caller persistent_ram_buffer_map() handles NULL
correctly by returning -ENOMEM, but without this check, a NULL return
combined with request_mem_region() succeeding leaves resources in an
inconsistent state.

This is the ioremap() counterpart to commit 05363abc76 ("pstore:
ram_core: fix incorrect success return when vmap() fails") which fixed
a similar issue in the vmap() path.

Fixes: 404a604338 ("staging: android: persistent_ram: handle reserving and mapping memory")
Signed-off-by: Cole Leavitt <cole@unwrap.rs>
Link: https://patch.msgid.link/20260225235406.11790-1-cole@unwrap.rs
Signed-off-by: Kees Cook <kees@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-06-01 17:35:27 +02:00
..
blk.c pstore/blk: trivial typo fixes 2025-03-13 12:49:51 +01:00
ftrace.c ftrace: Have the callbacks receive a struct ftrace_regs instead of pt_regs 2020-11-13 12:14:55 -05:00
inode.c pstore: inode: Only d_invalidate() is needed 2026-06-01 17:35:10 +02:00
internal.h pstore: Move kmsg_bytes default into Kconfig 2020-12-01 12:09:17 -08:00
Kconfig pstore: Make sure CONFIG_PSTORE_PMSG selects CONFIG_RT_MUTEXES 2022-12-31 13:14:45 +01:00
Makefile pstore/blk: Introduce backend for block devices 2020-05-30 10:34:03 -07:00
platform.c pstore/platform: Add check for kstrdup 2023-11-20 11:08:13 +01:00
pmsg.c pstore: Revert pmsg_lock back to a normal mutex 2023-05-11 23:00:31 +09:00
ram.c pstore/ram: Fix crash when setting number of cpus to an odd number 2024-02-23 08:54:39 +01:00
ram_core.c pstore/ram: fix resource leak when ioremap() fails 2026-06-01 17:35:27 +02:00
zone.c pstore/zone: Add a null pointer check to the psz_kmsg_read 2024-04-13 13:01:43 +02:00