summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHamdy Abou El Anein <hamdy.aea@protonmail.com>2026-11-03 12:04:11 +0100
committerNicolas Schier <nsc@kernel.org>2026-11-07 14:11:15 +0100
commitbc34894976c2e2d21abf347b03a8c2addf548860 (patch)
treeaf0755b14ece197b8606ece181b09ec225c502c1 /scripts
parent131d86d09b60b9df66adfff06152e52414f3ed94 (diff)
downloadlinux-next-bc34894976c2e2d21abf347b03a8c2addf548860.tar.gz
linux-next-bc34894976c2e2d21abf347b03a8c2addf548860.zip
kbuild: detect module name collisions between '-' and '_'
Kbuild converts hyphens to underscores in KBUILD_MODNAME, and the module loader treats both characters as equivalent. However, modules-check.sh compares module basenames without normalization. Consequently, modules named foo-bar.o and foo_bar.o pass the conflict check even though they have the same effective module name. Normalize basenames before checking for duplicates, and use awk to show the original module paths in diagnostics. Preserve detection of exact duplicates and leave distinct names unaffected. Signed-off-by: Hamdy Abou El Anein <hamdy.aea@protonmail.com> Reviewed-by: Nathan Chancellor <nathan@kernel.org> Fixes: 3a48a91901c5 ("kbuild: check uniqueness of module names") Link: https://patch.msgid.link/20261103110411.11698-1-info@daylightlinux.ch Signed-off-by: Nicolas Schier <nsc@kernel.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/modules-check.sh13
1 files changed, 11 insertions, 2 deletions
diff --git a/scripts/modules-check.sh b/scripts/modules-check.sh
index 4c8da90de78e..3d12dc53b202 100755
--- a/scripts/modules-check.sh
+++ b/scripts/modules-check.sh
@@ -13,10 +13,19 @@ exit_code=0
# Check uniqueness of module names
check_same_name_modules()
{
- for m in $(sed 's:.*/::' "$1" | sort | uniq -d)
+ for m in $(sed 's:.*/::; s/-/_/g' "$1" | sort | uniq -d)
do
echo "error: the following would cause module name conflict:" >&2
- sed -n "/\/$m/s:^\(.*\)\.o\$: \1.ko:p" "$1" >&2
+ awk -v name="$m" '
+ {
+ basename = $0
+ sub(/^.*\//, "", basename)
+ gsub(/-/, "_", basename)
+ if (basename == name) {
+ sub(/\.o$/, ".ko")
+ print " " $0
+ }
+ }' "$1" >&2
exit_code=1
done
}