Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp1197478ybh; Sat, 3 Aug 2019 20:23:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAnQYHGCB4cCARddt9lpztJ8w0HATidGD3nn8gi4oWSKkvjtbcnP8GNyry2Hx2lejqeY9I X-Received: by 2002:a17:90a:db42:: with SMTP id u2mr11844465pjx.48.1564888985467; Sat, 03 Aug 2019 20:23:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564888985; cv=none; d=google.com; s=arc-20160816; b=wfaHNHXRmOf51hd+cqIrkjmWIffpHI+8/dMq+eAv5erVROqPnk3vz8+9anAeuk5p6S ETLxahQa5RvviXSV8GwGlTtiI6rHeR0Hhgh65IBky1z1QX4MqqUx9BpqX454ojeW5mFa 33PRL6ZeOt/GPg1HqAdMCzCxrqXzr79lH1qoLMhAb8dahvqxlTvKOe4/s9NVkmJAPXUn v7nJyBbSg4SYVfkCTsipXJCfL/M3HoiaJUToTpewiKxJgrPgX2/vHUO7z22jcov5xQWV +vywvW9DRz8LFDLenhiWBtSh+PMsAuu8Tg7zNNl5o62y6Kw5XrwzrpgCQ56m8iR0tIjD Q/nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=TazsGP7cxXXZSH2JMdVr/ycQv/4+Lei21hIYlZrb6xM=; b=KRxKB2FrBTBO0vA1Gv34G+s8zCeFlc1LX75oMLkZ6aKT2UW0+xe+RCG/cGmJPBoNCa 9pcFCzFALCwn2C454ZS1Z+jDtmYDcARP5mOunklHhnvZDsp1Z3HYzcgDwMbIys9UA8R5 9CkJMBm5NnM26ReJD8ztYv+QfEWVZNzFtEjTVG4OQFrUuAoO4tsRFcnyKaxXhku3Q9MJ 4LpLgLPyaGRM0AuuaFAoRZ5QIocoE4ajCNF0Gspk+g4lfateLWoDRb0KZQpBe+yyc+HP OD6qGNKyGPjHN2AsKUzjPRnkITW3edLGpJaaTMAW5o/0/AWSGC1YUly8eRdWfbHt4eHj UELg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@runbox.com header.s=rbselector1 header.b=mSZhvIMy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=runbox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i198si40967721pfe.228.2019.08.03.20.22.50; Sat, 03 Aug 2019 20:23:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@runbox.com header.s=rbselector1 header.b=mSZhvIMy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=runbox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392765AbfHCAf1 (ORCPT + 99 others); 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