[PATCH 2/2] padata: Free the padata_works when they're no longer needed

From: Eric Biggers

Date: Fri Jul 17 2026 - 13:19:17 EST


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@xxxxxxxxxx>
---
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