From patchwork Tue Dec 11 11:00:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 153421 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp474663ljp; Tue, 11 Dec 2018 03:01:50 -0800 (PST) X-Google-Smtp-Source: AFSGD/XbukC5bNWV7s4dbfktCJrRC9F5ZQMww4ZKvpWhtGV2HSFEq0GRIbsy1ig+QBSF9chEq59M X-Received: by 2002:a63:6cc:: with SMTP id 195mr14319888pgg.52.1544526110109; Tue, 11 Dec 2018 03:01:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544526110; cv=none; d=google.com; s=arc-20160816; b=bCaxsu/syx69f7/TaQbI0yCk6+15TtmDt3GFzC53Nl3/XxnpY8MNvGD8kOscQntQfB X/RKZUsFbGEyXFYkM0ni2wQBAAUxuPwhLkSfQU2BaroEM3yuP0Bwo2TXXj2KyQow4ZRr I30S7xGZwG4lMmaaq3reAuYAqLty8MxRgnq7dbDYJsLw3ppjJ+zZTSQdfrsYUsrTeF+Q v4gq6jgzUGaosjCgllK+nVYnuTBBfSfcZIan43XiS+X83KDZwwOSw8wcnz8lObB5bD52 hnPZNmTnXZkZf0qdZnp25z5R61cTKv2nJuwT9YIbswq9eOE5OnL6iTQLnU8X1EkUkJqM 4r7g== 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; bh=zSehz5sKi9aix5amSrmINjlwYVsoU6nXsGRPKh0lMLo=; b=sSKWPDy6sPQla08BBNWADsdwp6Qx0NrHdz0ncCStc9xOvcH9VGEsQjcODI8fSnAXAK /LMx7v0eSZ/iexhY4LWHiyQ4Br6NfiXLxwO1pOQkvO4ZULfe2G7mnPXSBJjG3JGHIkyF FDgJh/yiGYKEM7SoLn5Emer+UqG2PvzN7X/en6lRlVNgbowsIdvCLN9lskITc7xIjwEr STT+NDRyoHwHLWxJmCfm3PjKMLf52B6859bB9oER/31WKsOPG6cM2t21wnpdyBd4wuH6 uuSAIvX3cytfzdPzpy+IKs3fEW1qvlRhkhsz4kZ0A1nlyOqC2c6NBoIE+69wnEXUjFvp XhdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=p3CC9cwI; 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 o2si12985331pfb.166.2018.12.11.03.01.49; Tue, 11 Dec 2018 03:01:50 -0800 (PST) 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=p3CC9cwI; 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 S1726728AbeLKLBt (ORCPT + 31 others); Tue, 11 Dec 2018 06:01:49 -0500 Received: from conuserg-11.nifty.com ([210.131.2.78]:36709 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726601AbeLKLBo (ORCPT ); Tue, 11 Dec 2018 06:01:44 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id wBBB1C5d017210; Tue, 11 Dec 2018 20:01:14 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com wBBB1C5d017210 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1544526074; bh=zSehz5sKi9aix5amSrmINjlwYVsoU6nXsGRPKh0lMLo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p3CC9cwIqHRRCTrxDoVz7UVsAF5ni8sCGpeXSVsCaMb7fKKF/yga3871nqKxDOa4/ qToXkmvKntTs26LhMaSi46tBN+hOyqUF6UlJktpYkMGKqDdF/i3QhmdqQWUiMPiqui 1JBbB3XZ0OdXz7rARLFINBWFg0GriUxnI/49UUIdJp+xSFkp5w7WZV7B9cf8W3Gw8u 9m8m2ITJU3tmioLGXFjLYIQw2xDkIlu46VC6VnYJQG7LGOTZL4yeggPJkHhL0j+ica ZPMlN1DrpsE4lN04bQRI0n5Vv7sge295ax+unKo1EIH+UJttHubRmN/Z3KwP3QkPm/ AZP3gWXx+Nv/w== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Ulf Magnusson , linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 02/27] kconfig: fix memory leak when EOF is encountered in quotation Date: Tue, 11 Dec 2018 20:00:45 +0900 Message-Id: <1544526070-16690-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544526070-16690-1-git-send-email-yamada.masahiro@socionext.com> References: <1544526070-16690-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 An unterminated string literal followed by new line is passed to the parser (with "multi-line strings not supported" warning shown), then handled properly there. On the other hand, an unterminated string literal at end of file is never passed to the parser, then results in memory leak. [Test Code] ----------(Kconfig begin)---------- source "Kconfig.inc" config A bool "a" -----------(Kconfig end)----------- --------(Kconfig.inc begin)-------- config B bool "b\No new line at end of file ---------(Kconfig.inc end)--------- [Summary from Valgrind] Before the fix: LEAK SUMMARY: definitely lost: 16 bytes in 1 blocks ... After the fix: LEAK SUMMARY: definitely lost: 0 bytes in 0 blocks ... Eliminate the memory leak path by handling this case. Of course, such a Kconfig file is wrong already, so I will add an error message later. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.l | 2 ++ 1 file changed, 2 insertions(+) -- 2.7.4 diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index eeac64c..c2f577d 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -221,6 +221,8 @@ n [A-Za-z0-9_-] } <> { BEGIN(INITIAL); + yylval.string = text; + return T_WORD_QUOTE; } }