kconfig: fix segmentation fault in menuconfig search
Since commitd05377e184
("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. Commitd05377e184
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:d05377e184
("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>
This commit is contained in:
Родитель
fb3041d61f
Коммит
7a263a0402
|
@ -722,8 +722,8 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
|
||||||
if (!expr_eq(prop->menu->dep, prop->visible.expr))
|
if (!expr_eq(prop->menu->dep, prop->visible.expr))
|
||||||
get_dep_str(r, prop->visible.expr, " Visible if: ");
|
get_dep_str(r, prop->visible.expr, " Visible if: ");
|
||||||
|
|
||||||
menu = prop->menu->parent;
|
menu = prop->menu;
|
||||||
for (i = 0; menu && i < 8; menu = menu->parent) {
|
for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) {
|
||||||
bool accessible = menu_is_visible(menu);
|
bool accessible = menu_is_visible(menu);
|
||||||
|
|
||||||
submenu[i++] = menu;
|
submenu[i++] = menu;
|
||||||
|
@ -733,16 +733,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
|
||||||
if (head && location) {
|
if (head && location) {
|
||||||
jump = xmalloc(sizeof(struct jump_key));
|
jump = xmalloc(sizeof(struct jump_key));
|
||||||
|
|
||||||
if (menu_is_visible(prop->menu)) {
|
jump->target = location;
|
||||||
/*
|
|
||||||
* There is not enough room to put the hint at the
|
|
||||||
* beginning of the "Prompt" line. Put the hint on the
|
|
||||||
* last "Location" line even when it would belong on
|
|
||||||
* the former.
|
|
||||||
*/
|
|
||||||
jump->target = prop->menu;
|
|
||||||
} else
|
|
||||||
jump->target = location;
|
|
||||||
|
|
||||||
if (list_empty(head))
|
if (list_empty(head))
|
||||||
jump->index = 0;
|
jump->index = 0;
|
||||||
|
@ -758,13 +749,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
|
||||||
menu = submenu[i];
|
menu = submenu[i];
|
||||||
if (jump && menu == location)
|
if (jump && menu == location)
|
||||||
jump->offset = strlen(r->s);
|
jump->offset = strlen(r->s);
|
||||||
|
str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu));
|
||||||
if (menu == &rootmenu)
|
|
||||||
/* The real rootmenu prompt is ugly */
|
|
||||||
str_printf(r, "%*cMain menu", j, ' ');
|
|
||||||
else
|
|
||||||
str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu));
|
|
||||||
|
|
||||||
if (menu->sym) {
|
if (menu->sym) {
|
||||||
str_printf(r, " (%s [=%s])", menu->sym->name ?
|
str_printf(r, " (%s [=%s])", menu->sym->name ?
|
||||||
menu->sym->name : "<choice>",
|
menu->sym->name : "<choice>",
|
||||||
|
|
Загрузка…
Ссылка в новой задаче