]> git.baikalelectronics.ru Git - kernel.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)
commitd9ef1e4a33cfd69ee98d665c987f1a0c9a99c032
tree05718b142e802d81023a13df9b75aee0dc692f83
parent792532372cd1206c431aa7275a1e082f439b4c27
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