Skip to content

Commit ee5814d

Browse files
committed
fsverity: use register_sysctl_init() to avoid kmemleak warning
Since the fsverity sysctl registration runs as a builtin initcall, there is no corresponding sysctl deregistration and the resulting struct ctl_table_header is not used. This can cause a kmemleak warning just after the system boots up. (A pointer to the ctl_table_header is stored in the fsverity_sysctl_header static variable, which kmemleak should detect; however, the compiler can optimize out that variable.) Avoid the kmemleak warning by using register_sysctl_init() which is intended for use by builtin initcalls and uses kmemleak_not_leak(). Reported-by: Yi Zhang <[email protected]> Closes: https://lore.kernel.org/r/CAHj4cs8DTSvR698UE040rs_pX1k-WVe7aR6N2OoXXuhXJPDC-w@mail.gmail.com Cc: [email protected] Reviewed-by: Joel Granados <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Eric Biggers <[email protected]>
1 parent e67572c commit ee5814d

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

fs/verity/init.c

+1-6
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#include <linux/ratelimit.h>
1111

1212
#ifdef CONFIG_SYSCTL
13-
static struct ctl_table_header *fsverity_sysctl_header;
14-
1513
static struct ctl_table fsverity_sysctl_table[] = {
1614
#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
1715
{
@@ -28,10 +26,7 @@ static struct ctl_table fsverity_sysctl_table[] = {
2826

2927
static void __init fsverity_init_sysctl(void)
3028
{
31-
fsverity_sysctl_header = register_sysctl("fs/verity",
32-
fsverity_sysctl_table);
33-
if (!fsverity_sysctl_header)
34-
panic("fsverity sysctl registration failed");
29+
register_sysctl_init("fs/verity", fsverity_sysctl_table);
3530
}
3631
#else /* CONFIG_SYSCTL */
3732
static inline void fsverity_init_sysctl(void)

0 commit comments

Comments
 (0)