Received: by 10.213.65.68 with SMTP id h4csp2116006imn; Sun, 8 Apr 2018 20:06:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx49vYW8NxwGNRYhD8YumlfP1xS/eXgM0hy37wja5LTaa1BK6hvLeaQPM/IJMd0GfqGJWy1xI X-Received: by 10.98.59.4 with SMTP id i4mr27761210pfa.26.1523243209834; Sun, 08 Apr 2018 20:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243209; cv=none; d=google.com; s=arc-20160816; b=Ezew9ZjnOpDNE+5L64+5oStU3I1RaXQGwGfqa5zmM+RW3NgayN0a3BkG8JMYgqFR4X UzJtNQY1D5XKsBP2fe1L4RF1/qhxCbf01iWK/B1xbFDQPZK1mEs0jaIjf7ugIfH+HmH8 u0EO55S7+6+eJB0OAmuFROoBfmpP5WleHSJcvhkt69jqpfEpQQyTDzqLQW55moizkz7e BDzKv9ArSuFTEQpSWS8ktrRInswUKBa5fgIamL7emSiIxdSNFJGq0JJZgwZ1thxcL5eK UTX1/ArV78y5CGdBQf2v83SxbZUjNR0NUYHW3qvhwFIEFZ6cwbK6jCvOaBYUFhgP+EsU QDng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=r7mkdapx0/O++TAvu2cUZ1OmDCkILFYNQz2Dl2DcPo0=; b=EU8Cq2Jb/iAnxiEX+4Q5D76lRO7BHOrEfGlsr+lVDbLPNOkP9QLte6Z8PKeSWgwLOx 3Dl7jZ+i1ObkZ34Y9izNLs3J2YC7WFmFOSfHN+5/fmoY9Or0+HO5a5HCwqiMxfilqDg2 G7S+JdsRWO4A7EF0dGhj7r1FgJHHDUujhtJAPPm935/H6aJ9+hR0WaNaF2idK0C6FAC7 MGXz0zgkbE+spVxCF4XxPHL9lTz3PcmxACr0n5t7TE29d5E8j7tHvU/2VZ61eODVzvLU XHs7DXnxjSc5jVVxqg3v7GZjVcE3yTHPkyiKsGw8uRYLOhgwbUSqSwUz0Os/Rf/78z2W P39Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=ICi1x/sG; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a21si9863640pfn.281.2018.04.08.20.06.12; Sun, 08 Apr 2018 20:06:49 -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=@microsoft.com header.s=selector1 header.b=ICi1x/sG; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932294AbeDIAdV (ORCPT + 99 others); Sun, 8 Apr 2018 20:33:21 -0400 Received: from mail-sn1nam01on0094.outbound.protection.outlook.com ([104.47.32.94]:49836 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932267AbeDIAdJ (ORCPT ); Sun, 8 Apr 2018 20:33:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=r7mkdapx0/O++TAvu2cUZ1OmDCkILFYNQz2Dl2DcPo0=; b=ICi1x/sGCBposlyPiiAjnqCqJUrEVW+SODfY9IJpAZ25di/XRWsj5bSI9NKt9uUCxSz5t+RkY+cgn4T4Tk281qCTeGI9HzzQRpH1SJHbrO5f0Q43QOhLVGC54qKMi8izhB7fo6iMeqHFGX+1mWg1K+k4qNVDdYevbJsGkVMjgXc= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0902.namprd21.prod.outlook.com (52.132.132.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:33:05 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:33:05 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Ulf Magnusson , Masahiro Yamada , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 233/293] kconfig: Fix automatic menu creation mem leak Thread-Topic: [PATCH AUTOSEL for 4.9 233/293] kconfig: Fix automatic menu creation mem leak Thread-Index: AQHTz5lTgD6CTPYQrEekGUR5DJuBEw== Date: Mon, 9 Apr 2018 00:25:55 +0000 Message-ID: <20180409002239.163177-233-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0902;7:Swz68mu2EdG1aOnd0m3YvOB27u7m/ferBtw1w8llsmDpH1KkidtAJPkmo22Y7kBofrjgXekRpvWdNwr4YGeP9rBFmuglRU8LK7sQkiIgv3Q2DM5uzQLRkDrKaC599FF/34sBFOCQ1eAJpk1rD5DOUrK1Chc8KcPjpexHOw5Gx4RunK3hqu0vC4lG0TKBj0X8dNZSHPhlkTRveIaEFt947pQXt7nbslxyMZeWp6VxaKyx/3MwWIiJGXAOtK4U4Coc;20:tyOQLYCbsi6172LXnCXUyVlheoCL7NuFOg8N8vxIq1WyEj8ooouzPODvFaP0s5aSLFYpbhwRSvtDAV5N5+2L8VRiB6Qp4c5w62rjBsAvFAoo6scZH3RByycK562+eGgDVB7uMcqfZV8af5NodO5XpcPNvBTZpXtvE+wIHZEQr5c= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: dc355f05-cb7c-488f-d08f-08d59db1761e x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0902; x-ms-traffictypediagnostic: DM5PR2101MB0902: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(85827821059158); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0902;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0902; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(376002)(396003)(39860400002)(39380400002)(346002)(199004)(189003)(5660300001)(478600001)(86612001)(3846002)(6116002)(106356001)(25786009)(6486002)(72206003)(10290500003)(8936002)(6436002)(76176011)(2616005)(6506007)(2900100001)(97736004)(26005)(486006)(10090500001)(36756003)(81166006)(8676002)(81156014)(102836004)(2906002)(99286004)(11346002)(476003)(3660700001)(66066001)(6512007)(575784001)(86362001)(53936002)(105586002)(186003)(5250100002)(14454004)(22452003)(6666003)(2501003)(446003)(7736002)(39060400002)(316002)(1076002)(110136005)(3280700002)(68736007)(54906003)(107886003)(4326008)(305945005)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0902;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: ekvznAfgRxUcwUgnWkCQt+G23Z8nRzNeZILDkvumHN1uS2HH+3/7BQb4gupyV8TDpjMhozTpnhh7fH3AH8MShwcztT/g6HRxt0c9hwU35CpxQhbRU5cR2v0LHkqccbXhkWsTwcydYSSSGbl/8Tl+sFmX33ky/pjk6hp4WvFVDDBVqaPRV00nxnJ1D4m/etKNYWQx4ikMQygrRTB9qSgLTZK3mpt4olwujuyLhJbT1TbxJkKoJlaHJIxihJ4ixdD3pTp2AmVJnQFBBTG0VcN8mtVbfv6+sDfMjjiEperzh1EEtvFR7LxmpXTz6+R9zN0lCSqS6GpgFRUY4MR6fvYyLAAGHrPYPD3cImOEp+myBUSNqvsQMR1k3YVuLOqvZTOT8O5qLB3OifQA4tUwGChT6dj+acU5DMDIG2KR9m+ZDgs= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc355f05-cb7c-488f-d08f-08d59db1761e X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:25:55.4255 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0902 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ulf Magnusson [ Upstream commit ae7440ef0c8013d68c00dad6900e7cce5311bb1c ] expr_trans_compare() always allocates and returns a new expression, giving the following leak outline: ... *Allocate* basedep =3D expr_trans_compare(basedep, E_UNEQUAL, &symbol_no); ... for (menu =3D parent->next; menu; menu =3D menu->next) { ... *Copy* dep2 =3D expr_copy(basedep); ... *Free copy* expr_free(dep2); } *basedep lost!* Fix by freeing 'basedep' after the loop. Summary from Valgrind on 'menuconfig' (ARCH=3Dx86) before the fix: LEAK SUMMARY: definitely lost: 344,376 bytes in 14,349 blocks ... Summary after the fix: LEAK SUMMARY: definitely lost: 44,448 bytes in 1,852 blocks ... Signed-off-by: Ulf Magnusson Signed-off-by: Masahiro Yamada Signed-off-by: Sasha Levin --- scripts/kconfig/menu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index aed678e8a777..4a61636158dd 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -364,6 +364,7 @@ void menu_finalize(struct menu *parent) menu->parent =3D parent; last_menu =3D menu; } + expr_free(basedep); if (last_menu) { parent->list =3D parent->next; parent->next =3D last_menu->next; --=20 2.15.1