]> git.ipfire.org Git - thirdparty/linux.git/commit
modpost: simplify mod->name allocation
authorMasahiro Yamada <masahiroy@kernel.org>
Mon, 30 May 2022 09:01:38 +0000 (18:01 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Sat, 4 Jun 2022 21:20:57 +0000 (06:20 +0900)
commit8c9ce89c5b63028dd3be43807f10b009cd2c6e51
tree05718b142e802d81023a13df9b75aee0dc692f83
parentb42d2306502419688190aa6dd4dab4a6def24b3d
modpost: simplify mod->name allocation

mod->name is set to the ELF filename with the suffix ".o" stripped.

The current code calls strdup() and free() to manipulate the string,
but a simpler approach is to pass new_module() with the name length
subtracted by 2.

Also, check if the passed filename ends with ".o" before stripping it.

The current code blindly chops the suffix:

    tmp[strlen(tmp) - 2] = '\0'

It will cause buffer under-run if strlen(tmp) < 2;

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
scripts/mod/modpost.c