Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934525Ab3EGClq (ORCPT ); Mon, 6 May 2013 22:41:46 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:62745 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758757Ab3EGCln (ORCPT ); Mon, 6 May 2013 22:41:43 -0400 Message-ID: <518869BB.2020808@huawei.com> Date: Tue, 7 May 2013 10:40:59 +0800 From: Li Zefan User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 MIME-Version: 1.0 To: Andrew Morton CC: Michal Marek , Weng Meiling , Libo Chen , LKML , , Borislav Petkov Subject: [PATCH] menuconfig: fix NULL pointer dereference when searching a symbol Content-Type: text/plain; charset="GB2312" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.135.68.215] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1884 Lines: 56 Searching PPC_EFIKA results segmentation fault, and it's because get_symbol_prop() returns NULL. In this case CONFIG_PPC_EFIKA is defined in arch/powerpc/platforms/ 52xx/Kconfig, so it won't be parsed if ARCH!=PPC, but menuconfig knows this symbol when it parses sound/soc/fsl/Kconfig: config SND_MPC52xx_SOC_EFIKA tristate "SoC AC97 Audio support for bbplan Efika and STAC9766" depends on PPC_EFIKA This bug was introduced by commit bcdedcc1afd6 ("menuconfig: print more info for symbol without prompts"). Reported-by: Borislav Petkov Signed-off-by: Li Zefan --- scripts/kconfig/menu.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 826da66..b5c7d90 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -600,14 +600,18 @@ void get_symbol_str(struct gstr *r, struct symbol *sym, } for_all_prompts(sym, prop) get_prompt_str(r, prop, head); + prop = get_symbol_prop(sym); - str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name, - prop->menu->lineno); - if (!expr_is_yes(prop->visible.expr)) { - str_append(r, _(" Depends on: ")); - expr_gstr_print(prop->visible.expr, r); - str_append(r, "\n"); + if (prop) { + str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name, + prop->menu->lineno); + if (!expr_is_yes(prop->visible.expr)) { + str_append(r, _(" Depends on: ")); + expr_gstr_print(prop->visible.expr, r); + str_append(r, "\n"); + } } + hit = false; for_all_properties(sym, prop, P_SELECT) { if (!hit) { -- 1.8.0.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/