From patchwork Thu May 17 06:16:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 136117 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1884985lji; Wed, 16 May 2018 23:28:30 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoH2asnHCq17lNwyMlJhkcl+GqOAVQJ0NKuLstn/9jIIHNpDEQFCzEcE5sqVHymD4JSN7CN X-Received: by 2002:a65:46c1:: with SMTP id n1-v6mr3205338pgr.62.1526538509967; Wed, 16 May 2018 23:28:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526538509; cv=none; d=google.com; s=arc-20160816; b=sk2m3PEhAGMqsR2WP8E+KJRlAf7BN8SsI1SKrMqLJCjVpIIrKkL65E4eVmkvOWwAWe U+LcQndM8lOxykOe9XDYSwVwXYUQN0m4E0AaApk33hMs1Lj5zNcNNyBiCWn6O65zKolB 0dmA2xFrSjtmw4juxPtrboBINvpc7Kv9ARU0g1wxSa8uZp8w3n+wZyNuofWFj603KVFB K9NsH2YYroRiRKXha2yt2e/F8Ddy1IDFRfG7fDzRQM2Isv3j7bATUEajP8AnfQybhmBp 5/DSa9Ctdkme1p/Bqy53h0DFbQTBUtBzMu81sFAJH2apHA27PxMpj4D6jwmFrOn2xGYa SOCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=W1m5Kr1L3BQFUW2WdW84BiwWbl8nKG77TmQ2wdZLdqs=; b=alOagBIeJDV0tLbs8oyHMUBe0Xxw3HAGhJz7mBGCqkEqsE+jr2xZLmya9W32Nd2Edw hbaB5NRaTbFuGThjSvFd5L88AAk3m8DYogSmVNPfXU6xqaLASfNiy2AfWNuh0WRCi6cR pJRuo29o+H5v+ucwpOE4hy45vB9/IYax52d/hRpjrxsrmFI370EkzWnyA70crXDVVnKj 68WKZiVF+h0wXC92lOHIlYV6EZk3+tdoi+ZttA9J3KXe5A9hwayJUzKjDQm9dmM6ABcn jAtZ6XQNgdZJfNwNPlFBkVdTUlMzPnf4SWv6EplM/83ymAKQsgjlflKUQeKOSGx1GWyQ N9Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=OUBS9ew3; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n127-v6si3444768pga.523.2018.05.16.23.28.29; Wed, 16 May 2018 23:28:29 -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=@nifty.com header.s=dec2015msa header.b=OUBS9ew3; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751984AbeEQG2Z (ORCPT + 29 others); Thu, 17 May 2018 02:28:25 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:24167 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751047AbeEQGSv (ORCPT ); Thu, 17 May 2018 02:18:51 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id w4H6HbU2002841; Thu, 17 May 2018 15:17:42 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com w4H6HbU2002841 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1526537863; bh=W1m5Kr1L3BQFUW2WdW84BiwWbl8nKG77TmQ2wdZLdqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OUBS9ew3DqPQDA5bOeDUmGMpvlP6M3HucOkG66bD1T95/CTVMJYT50GsVGleijMgs 7rF/ZH7FW8wOsesEtTrOyMkpZJA+BflZcZcgMjEWT1AZdSR9gvxr82hUVI2yqrDeYE wJKeEjijF+EohvxQYCN579B7WaWs10BbKisQMRfDsoumNgaBjbG2frtMqqPivxXxuZ SEFI5x9iUE4AMTE7coBb9xDjl1K8rcdaLu6uiYJgrjzQbQ6o7pzJftJf3M7Rw+UcyS G9Ow2pGWpWZqyQ2aPZVL6zN/43yowPQWTsS0hrwmIOdcaJmIPusb2ZJYxTwTwdTDR2 FWRsPYrkrVRdg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Linus Torvalds , Sam Ravnborg , Ulf Magnusson , "Luis R . Rodriguez" , linux-kernel@vger.kernel.org, Nicholas Piggin , Kees Cook , Emese Revfy , x86@kernel.org, Masahiro Yamada Subject: [PATCH v4 04/31] kconfig: remove string expansion in file_lookup() Date: Thu, 17 May 2018 15:16:43 +0900 Message-Id: <1526537830-22606-5-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526537830-22606-1-git-send-email-yamada.masahiro@socionext.com> References: <1526537830-22606-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are two callers of file_lookup(), but there is no more reason to expand the given path. [1] zconf_initscan() This is used to open the first Kconfig. sym_expand_string_value() has never been used in a useful way here; before opening the first Kconfig file, obviously there is no symbol to expand. If you use expand_string_value() instead, environments in KBUILD_KCONFIG would be expanded, but I do not see practical benefits for that. [2] zconf_nextfile() This is used to open the next file from 'source' statement. Symbols in the path like "arch/$SRCARCH/Kconfig" needed expanding, but it was replaced with the direct environment expansion. The environment has already been expanded before the token is passed to the parser. By the way, file_lookup() was already buggy; it expanded a given path, but it used the path before expansion for look-up: if (!strcmp(name, file->name)) { Signed-off-by: Masahiro Yamada Reviewed-by: Kees Cook Reviewed-by: Ulf Magnusson --- Changes in v4: None Changes in v3: None Changes in v2: - Simplify the patch. Just remove text expansion. scripts/kconfig/util.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.7.4 diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 807147e..790967df 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -14,18 +14,16 @@ struct file *file_lookup(const char *name) { struct file *file; - char *file_name = sym_expand_string_value(name); for (file = file_list; file; file = file->next) { if (!strcmp(name, file->name)) { - free(file_name); return file; } } file = xmalloc(sizeof(*file)); memset(file, 0, sizeof(*file)); - file->name = file_name; + file->name = xstrdup(name); file->next = file_list; file_list = file; return file;