Skip to contentSkip to conversation

modpost: add missing else to the "of" check

PATCH In review Mauricio Faria de Oliveira 2 participants 2 messages Sep 28, 2023 – Sep 30, 2023 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 modpost: add missing else to the "of" check

Without this 'else' statement, an "usb" name goes into two handlers:
the first/previous 'if' statement _AND_ the for-loop over 'devtable', but the latter is useless as it has no 'usb' device_id entry anyway.

Tested with allmodconfig before/after patch; no changes to *.mod.c:

git checkout v6.6-rc3
make -j$(nproc) allmodconfig
make -j$(nproc) olddefconfig

make -j$(nproc)
find . -name '*.mod.c' | cpio -pd /tmp/before

# apply patch

make -j$(nproc)
find . -name '*.mod.c' | cpio -pd /tmp/after

diff -r /tmp/before/ /tmp/after/
# no difference

Fixes acbef7b76629 ("modpost: fix module autoloading for OF devices with generic compatible property")
---
 scripts/mod/file2alias.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/mod/file2alias.c +1 -1
index 38120f932b0d..7056751c29b1 100644
@@ -1604,7 +1604,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
 	/* First handle the "special" cases */
 	if (sym_is(name, namelen, "usb"))
 		do_usb_table(symval, sym->st_size, mod);
-	if (sym_is(name, namelen, "of"))
+	else if (sym_is(name, namelen, "of"))
 		do_of_table(symval, sym->st_size, mod);
 	else if (sym_is(name, namelen, "pnp"))
 		do_pnp_device_entry(symval, sym->st_size, mod);
Signature · 1 line
2.39.2
#1 lore raw
Quoted 19 lines · Mauricio Faria de Oliveira

Without this 'else' statement, an "usb" name goes into two handlers:
the first/previous 'if' statement _AND_ the for-loop over 'devtable', but the latter is useless as it has no 'usb' device_id entry anyway.

Tested with allmodconfig before/after patch; no changes to *.mod.c:

git checkout v6.6-rc3
make -j$(nproc) allmodconfig
make -j$(nproc) olddefconfig

make -j$(nproc)
find . -name '*.mod.c' | cpio -pd /tmp/before

# apply patch

make -j$(nproc)
find . -name '*.mod.c' | cpio -pd /tmp/after

Quoted 6 lines

diff -r /tmp/before/ /tmp/after/
# no difference

Fixes acbef7b76629 ("modpost: fix module autoloading for OF devices with generic compatible property")

---

Applied to linux-kbuild/fixes.
Thanks.

--
Best Regards
Masahiro Yamada