From patchwork Sat Aug 3 10:02:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "M. Vefa Bicakci" X-Patchwork-Id: 11074343 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C522213B1 for ; Sat, 3 Aug 2019 10:02:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABBA3288EE for ; Sat, 3 Aug 2019 10:02:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E88B288F4; Sat, 3 Aug 2019 10:02:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20B22288EE for ; Sat, 3 Aug 2019 10:02:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388298AbfHCKCi (ORCPT ); Sat, 3 Aug 2019 06:02:38 -0400 Received: from aibo.runbox.com ([91.220.196.211]:53114 "EHLO aibo.runbox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388294AbfHCKCi (ORCPT ); Sat, 3 Aug 2019 06:02:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=rbselector1; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=h+gdKezhnZxQ2ykgMTawflCtKVKbt31AwdXjqem/yp4=; b=kXg+/nu/KXVcgabR+VYTZ+FOFH B5CRSmbOda9oLmMjdFY1MNMZ11kdtIUJ/kPzxLxXdomCwbcIiaGYMXGUsaXesn9utWvJb8jvJ7+Vf 7lQSjRURki80BihrM2Lf2+vSDHGH0JAiTmFnIiS6ZOTlZcxmLZ4zb/ZvtOcc1Y08961aiCcGc/LVX CKFIjG539a+5BPXBE15P6WZlLpvv4yw9kpGSHcEKJw6i9alPqchZRmDnmH8t9B9DEZIYlwYcURZDh 2T35Jk+MHD8KTqKDJy5mTrskGTb4KJzm+g/7xv4qGU8yElM0gn7yaUvgyVQ/+Q6MTJkY/80TBq4pa 8mgtGCZg==; Received: from [10.9.9.203] (helo=mailfront21.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1htqrv-0006ih-Ou; Sat, 03 Aug 2019 12:02:31 +0200 Received: by mailfront21.runbox with esmtpsa (uid:769847 ) (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) id 1htqrj-0007Lk-4g; Sat, 03 Aug 2019 12:02:19 +0200 From: "M. Vefa Bicakci" To: Masahiro Yamada Cc: =?utf-8?q?Joonas_Kylm=C3=A4l=C3=A4?= , Ulf Magnusson , Linux Kernel Mailing List , Linux Kbuild mailing list , linux-stable , "M. Vefa Bicakci" Subject: [PATCH v2] kconfig: Clear "written" flag to avoid data loss Date: Sat, 3 Aug 2019 06:02:12 -0400 Message-Id: <20190803100212.8227-1-m.v.b@runbox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- Changes since v1: * As suggested by Masahiro Yamada, instead of defining a new helper function to traverse over all symbols in a pre-defined order, use the for_all_symbols iterator. --- scripts/kconfig/confdata.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 1134892599da..3569d2dec37c 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -848,6 +848,7 @@ int conf_write(const char *name) const char *str; char tmpname[PATH_MAX + 1], oldname[PATH_MAX + 1]; char *env; + int i; bool need_newline = false; if (!name) @@ -930,6 +931,9 @@ int conf_write(const char *name) } fclose(out); + for_all_symbols(i, sym) + sym->flags &= ~SYMBOL_WRITTEN; + if (*tmpname) { if (is_same(name, tmpname)) { conf_message("No change to %s", name);