Thread (8 messages) 8 messages, 2 authors, 29d ago

[PATCH v8 4/4] alloc_tag: release the reservation when populate fails

flat view
COLD29d

From: Hao Ge <hao.ge@linux.dev>
Date: 2026-09-07 06:23:52
Also in: linux-mm, lkml, stable
Subsystem: memory management, memory management - allocation profiling (alloc tag), the rest · Maintainers: Andrew Morton, Suren Baghdasaryan, Linus Torvalds

Revision v8 of 5 in this series.

Revisions (5)
  1. v7 [diff vs current]
  2. v8 current
  3. v9 [diff vs current]
  4. v10 [diff vs current]
  5. v11 [diff vs current]
vm_module_tags_populate() can fail after the reservation was stored
in the maple tree, and the error return leaks the entry, since a
failed load never unloads the module. Release it.

Fixes: 0f9b685626da ("alloc_tag: populate memory for module tags as needed")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Hao Ge <hao.ge@linux.dev>
---
 mm/alloc_tag.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/mm/alloc_tag.c b/mm/alloc_tag.c
index 248496470904..3c25475becbc 100644
--- a/mm/alloc_tag.c
+++ b/mm/alloc_tag.c
@@ -971,6 +971,7 @@ static void *reserve_module_tags(struct module *mod, unsigned long size,
 			shutdown_mem_profiling(true);
 			pr_err("Failed to allocate memory for allocation tags in the module %s. Memory allocation profiling is disabled!\n",
 			       mod->name);
+			release_module_tags(mod, false);
 			return ERR_PTR(grow_res);
 		}
 	}
-- 
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help