All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: linux-crypto@vger.kernel.org, Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-kernel@vger.kernel.org,
	Daniel Jordan <daniel.m.jordan@oracle.com>,
	Steffen Klassert <steffen.klassert@secunet.com>,
	Eric Biggers <ebiggers@kernel.org>
Subject: [PATCH 2/2] padata: Free the padata_works when they're no longer needed
Date: Fri, 17 Jul 2026 10:18:31 -0700	[thread overview]
Message-ID: <20260717171831.27994-3-ebiggers@kernel.org> (raw)
In-Reply-To: <20260717171831.27994-1-ebiggers@kernel.org>

The memory pointed to by 'padata_works' is never freed.

Originally this was necessary because it was used to support the
serialized job APIs used by pcrypt, which can be used long after boot.

However, now that's been removed, and the remaining code in padata.c is
used only at boot time.  The pointer 'padata_works' is now __initdata.

The result is that this essentially turned into a memory leak.  Fix it.

Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
 kernel/padata.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/kernel/padata.c b/kernel/padata.c
index e7f89e3e44e9..a28fe0c4f66b 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -230,3 +230,12 @@ void __init padata_init(void)
 	for (i = 0; i < possible_cpus; ++i)
 		list_add(&padata_works[i].pw_list, &padata_free_works);
 }
+
+static int __init padata_exit(void)
+{
+	kfree(padata_works);
+	padata_works = NULL;
+	INIT_LIST_HEAD(&padata_free_works);
+	return 0;
+}
+late_initcall_sync(padata_exit);
-- 
2.55.0


  parent reply	other threads:[~2026-07-17 17:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17 17:18 [PATCH 0/2] More padata cleanups Eric Biggers
2026-07-17 17:18 ` [PATCH 1/2] padata: Mark remaining code as __init and data as __initdata Eric Biggers
2026-07-17 20:34   ` Daniel Jordan
2026-07-17 17:18 ` Eric Biggers [this message]
2026-07-17 20:35   ` [PATCH 2/2] padata: Free the padata_works when they're no longer needed Daniel Jordan

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=20260717171831.27994-3-ebiggers@kernel.org \
    --to=ebiggers@kernel.org \
    --cc=daniel.m.jordan@oracle.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.