Received: by 10.213.65.68 with SMTP id h4csp2111819imn; Sun, 8 Apr 2018 20:01:16 -0700 (PDT) X-Google-Smtp-Source: AIpwx48t0ptK0o323ka0jSNKgay2eMumRbJgtUtSOOukxVwpOq6tDRPffExqLHzF2KmODIUgYmin X-Received: by 2002:a17:902:bc82:: with SMTP id bb2-v6mr7581950plb.369.1523242876333; Sun, 08 Apr 2018 20:01:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523242876; cv=none; d=google.com; s=arc-20160816; b=ktkMZDCui1G9M8VtawRnbwBVUW70N9OdPHhwTEioQYfcoVvSBtTUnwfpQQ/JBiFbk8 QS5oB4dOlMJLO6Jy4MwbcL5HgS/9bwnTf8RTIyCyKzIS1vS2QHkRFJTC8uWbG0vH/0XM FwF5lrQ41nM9scCUBKH1uDBZ7X94CIE8JeQExbUx5CFW7e5Q4/D/AjNpV88Sx2/krAs7 jvtAu0RJQfJJRMMfo91PkDohvXn06LulZUrFzNfJpNujl1wGiqYWc4KP6pGJskB/y1cx v89eZMv+EpdhsT7GTKSBWwaASL3kaYYTk9YFPfREuH1OX7zR9P8ew2erM0Qr+E9zEt3i ic0A== 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=NVdslaOFl7DXblFhtaOiH7vOpo9R3RS176rq1db5QI4=; b=qdFjmYPOTD1Wn02jl28G9mmtCmh+opmmwteLPem0GMzD83U7NmdBE5fOnHn5Zuwc4i EEnUE62rSY65KY1ZavKPOLSmnuZ4tyubIJ8Hg06eQGf8/L7dNsG90p2IhuxNKmAUjeFd m0b1BlAmTyT1/pCj1KPwa2YVByJvGZ/B4TYZEc4keZ8zfSw5YpjEEvt31ilCCN9Z2Vnp mjKDtiE9uQ/D7KYXEtQw0fupZkbWuNISvVo9Fy7PJVLd2uujGmzke1ja1mWvsbNnx+Hm qc/2CRSGJNgg0l5SDmM8KskKlzoKuio8tIIIqfEeK6RaSAX43L3tdOfm1jwM/3OwF2Mn AZvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=hgdrhbju; 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 e63-v6si13724120plb.91.2018.04.08.20.00.39; Sun, 08 Apr 2018 20:01:16 -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=hgdrhbju; 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 S1753562AbeDIASQ (ORCPT + 99 others); Sun, 8 Apr 2018 20:18:16 -0400 Received: from mail-co1nam03on0107.outbound.protection.outlook.com ([104.47.40.107]:43410 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753398AbeDIASI (ORCPT ); Sun, 8 Apr 2018 20:18:08 -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=NVdslaOFl7DXblFhtaOiH7vOpo9R3RS176rq1db5QI4=; b=hgdrhbjuzLC56FBfh/uuTVjqGEfOabU9/Pk0+2/opPMm87F8SG4TFxFEyGeo+iiA9eu60Eoz4NPHaCk0h6Fk0vdzo0BqYyRF+yrp36PEYfMOGTx0RKJN17S7NP1uH61gKmV/NCkhRBYwi/6fKrDdo7T9Up0fDQiITGuS4I7PNgQ= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1046.namprd21.prod.outlook.com (52.132.128.15) 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:17:54 +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:17:54 +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.15 055/189] kconfig: Fix automatic menu creation mem leak Thread-Topic: [PATCH AUTOSEL for 4.15 055/189] kconfig: Fix automatic menu creation mem leak Thread-Index: AQHTz5gl1XbFDKRES0eyrQF4bxFm1Q== Date: Mon, 9 Apr 2018 00:17:29 +0000 Message-ID: <20180409001637.162453-55-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-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;DM5PR2101MB1046;7:owmwSunMa7e6HEe1ZL1JwWCC1S+J4zfJh6VkLSlU4E1wpo+MZ4rghWAZgX0zHRBoVTYJDZWGhk1TJyLfPFDlQRvY201e7q3iDMWOcRjJD13DQFf20AIVdFjUd4euTShosZXo/9x97NVJs0/RCJhz8JVifieYnhKkCeKFiMHS1AOmZB0Y03pR4xCV1b7rrbbBgjiE1uqNmjUNfIQNUTGPwkSWHP5mDNzqNlTWqNsbggupmy3VcDUAm8WvGMHs+91T;20:zNzit4MHU6KY1JcyDF3sDZFiowGPZJZAyamBukeqSJCxggMs+k445PbH/5hx+dyuRtjs59TrCBVmUX+EOzveBKQcB6bF9RxME/ToeKWlIkLz4hBShiaLAE8xfY0orJonLCIZf2WycwLoVLit4yS40GtmZliQCyZUWQmADf45e/E= X-MS-Office365-Filtering-Correlation-Id: 1a3abe70-366e-472e-57fb-08d59daf5707 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(48565401081)(2017052603328)(7193020);SRVR:DM5PR2101MB1046; x-ms-traffictypediagnostic: DM5PR2101MB1046: 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)(3231221)(944501327)(52105095)(10201501046)(3002001)(93006095)(93001095)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(6072148)(201708071742011);SRVR:DM5PR2101MB1046;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1046; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(346002)(376002)(396003)(366004)(39860400002)(199004)(189003)(36756003)(575784001)(186003)(11346002)(446003)(476003)(2616005)(7736002)(5660300001)(26005)(10290500003)(478600001)(106356001)(6666003)(68736007)(10090500001)(54906003)(3846002)(22452003)(6116002)(86612001)(110136005)(99286004)(86362001)(72206003)(305945005)(76176011)(102836004)(6506007)(486006)(316002)(3280700002)(3660700001)(81166006)(81156014)(8676002)(2906002)(14454004)(2900100001)(97736004)(6486002)(8936002)(1076002)(6512007)(6436002)(105586002)(39060400002)(25786009)(4326008)(2501003)(5250100002)(53936002)(66066001)(107886003)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1046;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: +UiJ7KM0ateyizgRdaWMbqm/5E7I3kuVnvkChL2ExZntokVCU1PiBkD6iVT5R44J5ESssUuZxMQIYJg+X8qTjsmwL5BahhgcDYypkWUPnJhRCMtCgWI/q1qaEEPIw1fQ5/74wocaWH8UtK16HY7hvIYzqIDNeMP932835feyLkYCzkMA3NM0ZA9ZRrAGVWjb2HBnximm9dUkH24c8v7R1NI+EoCK2M1ha8kiD9PrnnfmArBkdTELjc3H/B0xC2gEsAh0agybYvIltjfkocd5j6iWf6CKJzbqLZ2f9/L2qsA9DuC2pVuzRwMEDv+kvaBb12wPeGHoyt8hplg7+6GBhYbwERrXJ8UQplPU91J62b5jkpwlBVSgytZsIU3syLGG3isZSyVTiBJXIk28dFsGLdLuzruIjqQvzVUnnPpE2GA= 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: 1a3abe70-366e-472e-57fb-08d59daf5707 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:17:29.2751 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1046 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 e9357931b47d..749c2bd5fc51 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -372,6 +372,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