On 12/16/25 03:08, Greg Kroah-Hartman wrote:
6.18-stable review patch. If anyone has any objections, please let me know.
From: Jacob Keller jacob.e.keller@intel.com
[ Upstream commit e5e7ca66a7fc6b8073c30a048e1157b88d427980 ]
The python version of the kernel-doc parser emits some strange warnings with just a line number in certain cases:
$ ./scripts/kernel-doc -Wall -none 'include/linux/virtio_config.h' Warning: 174 Warning: 184 Warning: 190 Warning: include/linux/virtio_config.h:226 No description found for return value of '__virtio_test_bit' Warning: include/linux/virtio_config.h:259 No description found for return value of 'virtio_has_feature' Warning: include/linux/virtio_config.h:283 No description found for return value of 'virtio_has_dma_quirk' Warning: include/linux/virtio_config.h:392 No description found for return value of 'virtqueue_set_affinity'
I eventually tracked this down to the lone call of emit_msg() in the KernelEntry class, which looks like:
self.emit_msg(self.new_start_line, f"duplicate section name '{name}'\n")
This looks like all the other emit_msg calls. Unfortunately, the definition within the KernelEntry class takes only a message parameter and not a line number. The intended message is passed as the warning!
Pass the filename to the KernelEntry class, and use this to build the log message in the same way as the KernelDoc class does.
To avoid future errors, mark the warning parameter for both emit_msg definitions as a keyword-only argument. This will prevent accidentally passing a string as the warning parameter in the future.
Also fix the call in dump_section to avoid an unnecessary additional newline.
Fixes: e3b42e94cf10 ("scripts/lib/kdoc/kdoc_parser.py: move kernel entry to a class") Signed-off-by: Jacob Keller jacob.e.keller@intel.com Signed-off-by: Jonathan Corbet corbet@lwn.net Message-ID: 20251030-jk-fix-kernel-doc-duplicate-return-warning-v2-1-ec4b5c662881@intel.com Signed-off-by: Sasha Levin sashal@kernel.org
scripts/lib/kdoc/kdoc_parser.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser.py index 2376f180b1fa9..ccbc1fe4b7ccd 100644 --- a/scripts/lib/kdoc/kdoc_parser.py +++ b/scripts/lib/kdoc/kdoc_parser.py @@ -274,6 +274,8 @@ class KernelEntry: self.leading_space = None
self.fname = fname# State flags self.brcount = 0 self.declaration_start_line = ln + 1@@ -288,9 +290,11 @@ class KernelEntry: return '\n'.join(self._contents) + '\n' # TODO: rename to emit_message after removal of kernel-doc.pl
- def emit_msg(self, log_msg, warning=True):
- def emit_msg(self, ln, msg, *, warning=True): """Emit a message"""
log_msg = f"{self.fname}:{ln} {msg}"if not warning: self.config.log.info(log_msg) return@@ -336,7 +340,7 @@ class KernelEntry: # Only warn on user-specified duplicate section names if name != SECTION_DEFAULT: self.emit_msg(self.new_start_line,
f"duplicate section name '{name}'\n")
f"duplicate section name '{name}'") # Treat as a new paragraph - add a blank line self.sections[name] += '\n' + contents else:@@ -387,15 +391,15 @@ class KernelDoc: self.emit_msg(0, 'Python 3.7 or later is required for correct results')
- def emit_msg(self, ln, msg, warning=True):
- def emit_msg(self, ln, msg, *, warning=True): """Emit a message"""
log_msg = f"{self.fname}:{ln} {msg}"if self.entry:self.entry.emit_msg(log_msg, warning)
self.entry.emit_msg(ln, msg, warning=warning) return
log_msg = f"{self.fname}:{ln} {msg}"if warning: self.config.log.warning(log_msg) else:
On 6.18.2-rc1 and 6.17.13-rc2, this patch causes amd64 kernel builds with my usual configs to fail with the following error:
CC drivers/gpu/drm/i915/i915_driver.o Traceback (most recent call last): File "/home/barryn/src/linux/build-amd64/linux-6.18.2-rc1/./scripts/kernel-doc.py", line 339, in <module> main() File "/home/barryn/src/linux/build-amd64/linux-6.18.2-rc1/./scripts/kernel-doc.py", line 310, in main kfiles.parse(args.files, export_file=args.export_file) File "/home/barryn/src/linux/build-amd64/linux-6.18.2-rc1/scripts/lib/kdoc/kdoc_files.py", line 222, in parse self.parse_file(fname) File "/home/barryn/src/linux/build-amd64/linux-6.18.2-rc1/scripts/lib/kdoc/kdoc_files.py", line 120, in parse_file export_table, entries = doc.parse_kdoc() ^^^^^^^^^^^^^^^^ File "/home/barryn/src/linux/build-amd64/linux-6.18.2-rc1/scripts/lib/kdoc/kdoc_parser.py", line 1648, in parse_kdoc self.state_actions[self.state](self, ln, line) File "/home/barryn/src/linux/build-amd64/linux-6.18.2-rc1/scripts/lib/kdoc/kdoc_parser.py", line 1123, in process_normal self.reset_state(ln) File "/home/barryn/src/linux/build-amd64/linux-6.18.2-rc1/scripts/lib/kdoc/kdoc_parser.py", line 447, in reset_state self.entry = KernelEntry(self.config, ln) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/barryn/src/linux/build-amd64/linux-6.18.2-rc1/scripts/lib/kdoc/kdoc_parser.py", line 277, in __init__ self.fname = fname ^^^^^ NameError: name 'fname' is not defined make[6]: *** [scripts/Makefile.build:287: drivers/gpu/drm/i915/i915_driver.o] Error 1 make[6]: *** Deleting file 'drivers/gpu/drm/i915/i915_driver.o' make[5]: *** [scripts/Makefile.build:556: drivers/gpu/drm/i915] Error 2 make[4]: *** [scripts/Makefile.build:556: drivers/gpu/drm] Error 2 make[3]: *** [scripts/Makefile.build:556: drivers/gpu] Error 2 make[2]: *** [scripts/Makefile.build:556: drivers] Error 2 make[1]: *** [/home/barryn/src/linux/build-amd64/linux-6.18.2-rc1/Makefile:2010: .] Error 2 make: *** [Makefile:248: __sub-make] Error 2
Here is a minimal config to reproduce (make a .config with just these 6 lines, then run `make olddefconfig`):
CONFIG_64BIT=y CONFIG_EXPERT=y CONFIG_PCI=y CONFIG_DRM=y CONFIG_DRM_I915=y CONFIG_DRM_I915_WERROR=y
This bug happens if and only if CONFIG_DRM_I915_WERROR=y. (By the way, allyesconfig and allmodconfig set CONFIG_COMPILE_TEST=y, which disables CONFIG_DRM_I915_DEBUG and CONFIG_DRM_I915_WERROR. So neither allyesconfig nor allmodconfig reproduce this.)
It happens whether building for amd64 or i386 (so CONFIG_64BIT=y is not strictly necessary). It happens on both fully updated Debian 12 Bookworm and fully updated Debian 13 Trixie. It happens both when compiling natively on amd64 and when cross-compiling from an arm64 system.
It happens on 6.18.2-rc1 and 6.17.13-rc2, but not on 6.19-rc1. Also, if I revert this patch on 6.18.2-rc1 or 6.17.13-rc2, the bug no longer reproduces.