From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B90AC41514 for ; Sat, 3 Aug 2019 00:35:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E430A2087E for ; Sat, 3 Aug 2019 00:35:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="mSZhvIMy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392773AbfHCAf1 (ORCPT ); Fri, 2 Aug 2019 20:35:27 -0400 Received: from aibo.runbox.com ([91.220.196.211]:32998 "EHLO aibo.runbox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390153AbfHCAf0 (ORCPT ); Fri, 2 Aug 2019 20:35:26 -0400 X-Greylist: delayed 2543 seconds by postgrey-1.27 at vger.kernel.org; Fri, 02 Aug 2019 20:35:25 EDT DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=rbselector1; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-ID:Subject:Cc:To:From:Date; bh=TazsGP7cxXXZSH2JMdVr/ycQv/4+Lei21hIYlZrb6xM=; b=mSZhvIMybaEUGW2OxkQfP8J5QB igMTDE0QXHFlO3lb0R+yQULAbE3S+M1bMoVYT8uGb1mWkLiRm7XegpBzkz8DlRLMY5UCGefdlqo2f 0mgXs1D/giWOKJlfyzm8+shV6sYdI6cmF6cMDnoILREV66eFRjMRe3V+aOMe7rdAizXGE2WDZ2xiF vxTNK6a/awBRFGvn2hKDUkVWjdxbxfZ/WEm2Ay+6o5BvE2QDbXmXxPEiwplHhhQ+/6nq2IaTprvkF u2uz+j80/xZ338ZrqqrfuFKEHrWmo0me2j0EMZFuVgAITbhu7NFvsOV4B4qlC1vnvSiXlhkDcMGiu MFQ64LQw==; Received: from [10.9.9.203] (helo=mailfront21.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1hthM4-0003Go-ED; Sat, 03 Aug 2019 01:53:00 +0200 Received: by mailfront21.runbox with esmtpsa (uid:769847 ) (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) id 1hthLu-0002Rb-L9; Sat, 03 Aug 2019 01:52:51 +0200 Date: Fri, 2 Aug 2019 19:52:43 -0400 From: "M. Vefa Bicakci" To: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org, joonas.kylmala@iki.fi, ulfalizer@gmail.com, linux-stable , linux-kernel@vger.kernel.org Subject: Re: [PATCH] kconfig: fix missing choice values in auto.conf Message-ID: <20190802195243.09a87651@runbox.com> In-Reply-To: <20190712060709.20609-1-yamada.masahiro@socionext.com> References: <20190712060709.20609-1-yamada.masahiro@socionext.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, > conf_write() must be changed accordingly. Currently, it clears > SYMBOL_WRITE after the symbol is written into the .config file. This > is needed to prevent it from writing the same symbol multiple times in > case the symbol is declared in two or more locations. I added the new > flag SYMBOL_WRITTEN, to track the symbols that have been written. [snip] > diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c > index cbb6efa4a5a6..e0972b255aac 100644 > --- a/scripts/kconfig/confdata.c > +++ b/scripts/kconfig/confdata.c [snip] > @@ -903,7 +904,7 @@ int conf_write(const char *name) > fprintf(out, "\n"); > need_newline = false; > } > - sym->flags &= ~SYMBOL_WRITE; > + sym->flags |= SYMBOL_WRITTEN; The SYMBOL_WRITTEN flag is never cleared after being set in this function, which unfortunately causes data loss to occur when a user starts xconfig, gconfig, or nconfig and saves a config file more than once. Every save operation after the first one causes the saved .config file to contain only comments. I am appending a patch that resolves this issue. The patch is a bit ugly because of the code duplication, but it fixes this bug. (I have lightly tested the patch.) Even if the patch is not merged, I would appreciate it if this bug could be fixed. Thank you, Vefa === 8< === Patch Follows === >8 === From: "M. Vefa Bicakci" Date: Fri, 2 Aug 2019 17:44:40 -0400 Subject: [PATCH] kconfig: Clear "written" flag to avoid data loss Prior to this commit, starting nconfig, xconfig or gconfig, and saving the .config file more than once caused data loss, where a .config file that contained only comments would be written to disk starting from the second save operation. This bug manifests itself because the SYMBOL_WRITTEN flag is never cleared after the first call to conf_write, and subsequent calls to conf_write then skip all of the configuration symbols due to the SYMBOL_WRITTEN flag being set. This commit resolves this issue by clearing the SYMBOL_WRITTEN flag from all symbols before conf_write returns. Fixes: 8e2442a5f86e ("kconfig: fix missing choice values in auto.conf") Cc: linux-stable # 4.19+ Signed-off-by: M. Vefa Bicakci --- scripts/kconfig/confdata.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 1134892599da..24fe0c851e8c 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -840,6 +840,35 @@ int conf_write_defconfig(const char *filename) return 0; } +static void conf_clear_written_flag(void) +{ + struct menu *menu; + struct symbol *sym; + + menu = rootmenu.list; + while (menu) { + sym = menu->sym; + if (sym && (sym->flags & SYMBOL_WRITTEN)) + sym->flags &= ~SYMBOL_WRITTEN; + + if (menu->list) { + menu = menu->list; + continue; + } + + if (menu->next) { + menu = menu->next; + } else { + while ((menu = menu->parent)) { + if (menu->next) { + menu = menu->next; + break; + } + } + } + } +} + int conf_write(const char *name) { FILE *out; @@ -930,6 +959,8 @@ int conf_write(const char *name) } fclose(out); + conf_clear_written_flag(); + if (*tmpname) { if (is_same(name, tmpname)) { conf_message("No change to %s", name); -- 2.21.0