modpost: add missing else to the "of" check
authorMauricio Faria de Oliveira <mfo@canonical.com>
Thu, 28 Sep 2023 20:28:07 +0000 (17:28 -0300)
committerMasahiro Yamada <masahiroy@kernel.org>
Sun, 1 Oct 2023 05:24:34 +0000 (14:24 +0900)
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")
Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/mod/file2alias.c

index 38120f932b0dc1c9dcca19865223c9bb3881a844..7056751c29b1fb7171f70b29c79026363bcabd6b 100644 (file)
@@ -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);