From: sashiko-bot@kernel.org
To: "Hao Ge" <hao.ge@linux.dev>
Cc: linux-modules@vger.kernel.org
Subject: Re: [PATCH v10 6/6] alloc_tag: Defer /proc/allocinfo removal to a workqueue
Date: Tue, 15 Sep 2026 07:10:10 +0000 [thread overview]
Message-ID: <20260915071010.8C93B1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260915070001.113559-7-hao.ge@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mm: memory leak in alloc_tag_init() when proc_create() fails
--
commit 4e566e12e21d0ae73ee9a25235cceeeff9cef087
Author: Hao Ge <hao.ge@linux.dev>
alloc_tag: Defer /proc/allocinfo removal to a workqueue
shutdown_mem_profiling() calls remove_proc_entry() from
reserve_module_tags(), which runs under mod_lock held for write.
remove_proc_entry() waits for readers, and a reader takes mod_lock for
read in allocinfo_start(). This commit moves remove_proc_entry() to a
workqueue and relocates file creation to avoid panics.
> diff --git a/mm/alloc_tag.c b/mm/alloc_tag.c
> index 1ca0409b492b8..cfa0fc84b68f9 100644
> --- a/mm/alloc_tag.c
> +++ b/mm/alloc_tag.c
[ ... ]
> @@ -1358,16 +1366,10 @@ static int __init alloc_tag_init(void)
> return 0;
> }
>
> - if (!proc_create(ALLOCINFO_FILE_NAME, 0400, NULL, &allocinfo_proc_ops)) {
> - pr_err("Failed to create %s file\n", ALLOCINFO_FILE_NAME);
> - shutdown_mem_profiling(false);
> - return -ENOMEM;
> - }
> -
> res = alloc_mod_tags_mem();
> if (res) {
> pr_err("Failed to reserve address space for module tags, errno = %d\n", res);
> - shutdown_mem_profiling(true);
> + shutdown_mem_profiling(false);
> return res;
> }
>
> @@ -1375,10 +1377,16 @@ static int __init alloc_tag_init(void)
> if (IS_ERR(alloc_tag_cttype)) {
> pr_err("Allocation tags registration failed, errno = %pe\n", alloc_tag_cttype);
> free_mod_tags_mem();
> - shutdown_mem_profiling(true);
> + shutdown_mem_profiling(false);
> return PTR_ERR(alloc_tag_cttype);
> }
>
> + if (!proc_create(ALLOCINFO_FILE_NAME, 0400, NULL, &allocinfo_proc_ops)) {
> + pr_err("Failed to create %s file\n", ALLOCINFO_FILE_NAME);
> + shutdown_mem_profiling(false);
> + return -ENOMEM;
[Severity: Medium]
Does this code leak the memory allocated by alloc_mod_tags_mem()?
Since the proc_create() call was relocated to execute after
alloc_mod_tags_mem(), this error path seems to exit without unwinding the
previous allocation by calling free_mod_tags_mem(), directly introducing a
memory leak when procfs creation fails in mm/alloc_tag.c:alloc_tag_init().
> + }
> +
> return 0;
> }
> module_init(alloc_tag_init);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260915070001.113559-1-hao.ge@linux.dev?part=6
next prev parent reply other threads:[~2026-09-15 7:10 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 6:59 [PATCH v10 0/6] alloc_tag and module codetag section fixes Hao Ge
2026-09-15 6:59 ` [PATCH v10 1/6] alloc_tag: move release_module_tags() above reserve_module_tags() Hao Ge
2026-09-15 6:59 ` [PATCH v10 2/6] alloc_tag: clean up the populate failure path Hao Ge
2026-09-15 21:09 ` Suren Baghdasaryan
2026-09-16 6:01 ` Hao Ge
2026-09-16 16:31 ` Suren Baghdasaryan
2026-09-16 19:07 ` Suren Baghdasaryan
2026-09-17 1:12 ` Hao Ge
2026-09-17 2:32 ` Hao Ge
2026-09-18 16:35 ` Lorenzo Stoakes (ARM)
2026-09-28 9:53 ` Uladzislau Rezki
2026-09-28 9:57 ` Lorenzo Stoakes (ARM)
2026-09-28 11:09 ` Uladzislau Rezki
2026-09-28 15:09 ` Uladzislau Rezki
2026-09-28 15:16 ` Suren Baghdasaryan
2026-09-28 17:47 ` Uladzislau Rezki
2026-09-28 17:54 ` Suren Baghdasaryan
2026-09-29 8:28 ` Hao Ge
2026-09-15 6:59 ` [PATCH v10 3/6] module: introduce SH_ENTSIZE_STANDALONE for separately allocated sections Hao Ge
2026-09-17 17:25 ` Suren Baghdasaryan
2026-09-18 2:51 ` Hao Ge
2026-09-15 6:59 ` [PATCH v10 4/6] module: allocate codetag sections before the regular module layout Hao Ge
2026-09-18 0:05 ` Suren Baghdasaryan
2026-09-15 7:00 ` [PATCH v10 5/6] alloc_tag: skip percpu counter allocation when profiling is disabled Hao Ge
2026-09-18 0:53 ` Suren Baghdasaryan
2026-09-18 2:37 ` Hao Ge
2026-09-23 2:46 ` Suren Baghdasaryan
2026-09-15 7:00 ` [PATCH v10 6/6] alloc_tag: Defer /proc/allocinfo removal to a workqueue Hao Ge
2026-09-15 7:10 ` sashiko-bot [this message]
2026-09-18 1:09 ` Suren Baghdasaryan
2026-09-18 1:39 ` Hao Ge
2026-09-23 2:41 ` Suren Baghdasaryan
2026-09-23 6:55 ` Hao Ge
2026-09-15 18:23 ` [PATCH v10 0/6] alloc_tag and module codetag section fixes Suren Baghdasaryan
2026-09-16 5:03 ` Hao Ge
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260915071010.8C93B1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=hao.ge@linux.dev \
--cc=linux-modules@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox