]> git.baikalelectronics.ru Git - kernel.git/commit
kconfig: fix segmentation fault in menuconfig search
authorMasahiro Yamada <masahiroy@kernel.org>
Sun, 23 Oct 2022 19:10:55 +0000 (04:10 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Wed, 2 Nov 2022 08:32:05 +0000 (17:32 +0900)
commitdb32daa54513fc0ff138e916a547e8baaa133d3e
tree128cfc1fcb37738a43d7a0c84e9a25191e6e384b
parent2a8efb431833cab937b56ee594c3f5ada4c42a3d
kconfig: fix segmentation fault in menuconfig search

Since commit 00b1d983fb9d ("kconfig: Create links to main menu items
in search"), menuconfig shows a jump key next to "Main menu" if the
nearest visible parent is the rootmenu. If you press that jump key,
menuconfig crashes with a segmentation fault.

For example, do this:

  $ make ARCH=arm64 allnoconfig menuconfig

Press '/' to search for the string "ACPI". Press '1' to choose
"(1) Main menu". Then, menuconfig crashed with a segmentation fault.

The following code in search_conf()

    conf(targets[i]->parent, targets[i]);

results in NULL pointer dereference because targets[i] is the rootmenu,
which does not have a parent.

Commit 00b1d983fb9d tried to fix the issue of top-level items not having
a jump key, but adding the "Main menu" was not the right fix.

The correct fix is to show the searched item itself. This fixes another
weird behavior described in the comment block.

Fixes: 00b1d983fb9d ("kconfig: Create links to main menu items in search")
Reported-by: Johannes Zink <j.zink@pengutronix.de>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>
Tested-by: Johannes Zink <j.zink@pengutronix.de>
scripts/kconfig/menu.c