Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp1209864ybh; Sat, 3 Aug 2019 20:41:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJPSS5zHMuAy6aeDBgNo9YU1OPyaMt/xvKZz5/dWUJSSBSum8JLY4UF/phN53UKb/KvTxt X-Received: by 2002:a62:770e:: with SMTP id s14mr64892424pfc.150.1564890077580; Sat, 03 Aug 2019 20:41:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564890077; cv=none; d=google.com; s=arc-20160816; b=s/wCdWggj+X+xDwcXmRA+INieA5p+OMhIWe6EFGN3/u7Si5FnMTpNnQ9AA2r60pssA PvrSqR7aYrDeYl5mH5u2m/65EfDHMpZIQnYmF7vApJOPKL7RjQwR6LyNM/o68VV9QmJp MKSCFpRxsCkjs6f9ZQgp5dcZZyQMlpPbct5zw7n5JQfgLi81dKk2lSlCaO2VnOyB0I3k /EjX20ve8iM+yqV4HJ6mH+eJEeJNmTIwvCDfqKGxIvWc2Or8hhLCufr/GR0GyMDJNk5K UTO04ENya1HepKnf97I+pUJ+NRENfzrHWa3GFbtpSTvrejbG/cmgh/lhSHr6YYYltt5k n1Hw== 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:date:subject:cc:to:from :dkim-signature; bh=h+gdKezhnZxQ2ykgMTawflCtKVKbt31AwdXjqem/yp4=; b=cn6pg9i6AG1owgucopm84hwivyMu1zHYGGs/bHJL2FgbDMBqUNj4m7Y1Cg7g9plXAk FSsxpQP7GivOb+scYh1Y4GRzgxJMo+PUjMoDTJK+DH5BBgHd6wQnghGo1BFtzptV6xPr cqtR0TFvdYItoK3D/YxbPo921B4HbYfQao/Ndp4tP6hZVKfOpVbT9gGV+0u62LVAT9wa 9H29uchlYk1aFmlo9PKTqviOkRYeieqys5WNqt9DHsnyUthBRD1EQ4IZgzW6dB+hS7NM oEMCrIjI+Nem0Gx44HiwmIx12Su2+UdKPA/UPZGNAvVNvUZrvfOqePWFUhIkU03iQVCo OENA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@runbox.com header.s=rbselector1 header.b="kXg+/nu/"; 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 t27si39893440pgk.502.2019.08.03.20.41.02; Sat, 03 Aug 2019 20:41:17 -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="kXg+/nu/"; 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 S2388323AbfHCKCi (ORCPT + 99 others); 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=20Kylm=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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.21.0