diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 7578e21a711b45c8ecddc86ae280c7965e177cac..2322b12cb4cf4c71e92a85781f2ae13b61f2d3c3 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -3274,7 +3274,7 @@ int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
 
 #endif /* CONFIG_PROC_SYSCTL */
 
-#ifdef CONFIG_BPF_SYSCALL
+#if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
 static int proc_dointvec_minmax_bpf_stats(struct ctl_table *table, int write,
 					  void __user *buffer, size_t *lenp,
 					  loff_t *ppos)