diff --git a/scripts/check-sysctl-docs b/scripts/check-sysctl-docs
index 739afd766708a4d257083d969b700cb045143318..20274c63e7451a8722137e7077f4456f293f4e54 100755
--- a/scripts/check-sysctl-docs
+++ b/scripts/check-sysctl-docs
@@ -93,6 +93,7 @@ BEGINFILE {
     delete entries
     curtable = ""
     curentry = ""
+    delete vars
     if (debug) print "Processing file " FILENAME
 }
 
@@ -105,6 +106,7 @@ BEGINFILE {
 /^};$/ {
     curtable = ""
     curentry = ""
+    delete vars
 }
 
 curtable && /\.procname[\t ]*=[\t ]*".+"/ {
@@ -125,6 +127,24 @@ curtable && /\.procname[\t ]*=[\t ]*".+"/ {
     }
 }
 
+/kmemdup.*/ {
+    match($0, /([^ \t]+) *= *kmemdup\(([^,]+) *,/, names)
+    if (debug) print "Found variable " names[1] " for table " names[2]
+    if (names[2] in entries) {
+        vars[names[1]] = names[2]
+    }
+}
+
+/__register_sysctl_table.*/ {
+    match($0, /__register_sysctl_table\([^,]+, *"([^"]+)" *, *([^,]+)/, tables)
+    if (debug) print "Registering variable table " tables[2] " at " tables[1]
+    if (tables[1] == table && tables[2] in vars) {
+        for (entry in entries[vars[tables[2]]]) {
+            printentry(entry)
+        }
+    }
+}
+
 END {
     for (entry in documented) {
 	if (!seen[entry]) {