Received: by 10.213.65.68 with SMTP id h4csp2127346imn; Sun, 8 Apr 2018 20:24:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx49dDEgnxIkK+j/LswrHp3bNvXLN6ziYBC6x65PqJ6XhYYJ+DAzVVKU4OdPsbp89rLbOScAp X-Received: by 2002:a17:902:1744:: with SMTP id i62-v6mr37283850pli.62.1523244267988; Sun, 08 Apr 2018 20:24:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523244267; cv=none; d=google.com; s=arc-20160816; b=ogKXilx3I3CDIhQmMOnfLwb7g+YiTxVF5HWsaDXAd8LA+H0319D+D39/SoKDEKIKSI PaLn9mKD9wX6l5IWLMfehnznNSX6ddSMgvcXi3LC44ZnnheSiDu6pmcz4Ed5UzJVPQzX xLnZSX7Lcmd9BS0kZzTAKIAYPQw2cEDFo1QDS8cXFiaXBmXklRXuydUo89b7HhN6sAvu rLQMoKrLjQFnhV6aS0uLruNZ9Vabe4UvqPWF0+i5AELg2DML/zNAoVgfnSWNu9t7F8tS HJ1U85bmtoCzRYxj+jLi4GNBuE+z+nDVzsq8BYh/h2BZokxXhgrNvoZ4w249Z1AAbjhr vaHw== 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=q462wdI1RuX3ZQl0+jNfFgAiqkXhwD/8HFMfOUrXD4kTZttyVlmVnm84Db0+KALM6d CcYBs02qsqwzGR0hOin6+5L+PT96Ms80qsnwG8A5jFBHbWVDPNqj2NAMsA416tpoKYJT WIKfj5k//+mFr8qZJ8ShuD7ltGJNJTd2iz8Ac9gt5qwoc+i9Ya1Wi0NU0csSIOonDnWJ h+nLiuNqg+hgayrXirrvEuj9ePaXSMr5oAWec5P688ILlUgcxJWgnY+tPY5YuQcxhuuw JhRY0ZyfQXbdTPzecDuJRYeM113umrYDULZ0dWwpua0NkRRicBjYf0y7BNoSMq3ZXgnA B7vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=MbaVBDwC; 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 x11si10333825pgr.147.2018.04.08.20.23.50; Sun, 08 Apr 2018 20:24:27 -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=MbaVBDwC; 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 S1753076AbeDIDUj (ORCPT + 99 others); Sun, 8 Apr 2018 23:20:39 -0400 Received: from mail-sn1nam01on0134.outbound.protection.outlook.com ([104.47.32.134]:37792 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754726AbeDIAW7 (ORCPT ); Sun, 8 Apr 2018 20:22:59 -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=MbaVBDwCXuz+eGS4LsBxHkrq3BP635U1HaAwyHWLl4f80kn687POiv5T7jE+h9paQx6zFytD0jmYuTu3lQKAa5m7pwP1/jUEKmK0ZzZ5NXL4yVPTJq6koh/Q9PJzDL+Nqu8CdAlNXCINKuJF4Gbz3I0GUZRZg9jfsCqjhnhRB/Q= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1014.namprd21.prod.outlook.com (52.132.133.36) 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:22:55 +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:22:55 +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.14 047/161] kconfig: Fix automatic menu creation mem leak Thread-Topic: [PATCH AUTOSEL for 4.14 047/161] kconfig: Fix automatic menu creation mem leak Thread-Index: AQHTz5iNCoD5Z7A0MUW/OMGLFb71tg== Date: Mon, 9 Apr 2018 00:20:24 +0000 Message-ID: <20180409001936.162706-47-alexander.levin@microsoft.com> References: <20180409001936.162706-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001936.162706-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;DM5PR2101MB1014;7:PQbBfEoKfgDQHgxEs6nv+KloxXdGBXL/uea1g5N0pSFbK8c5nZvmfzZkOw9dRahcXNi7/UGeZUsprn6Qshp+lgVNAnqZb7tGRubKEnX/tbmV4xsfN141MgaY0N3PGVlUZ7FirgQ1+nIOadWrzzACIoPR3KmNDEEiph6zeB+fyqvYLfpcModYWPTYvQ9QGUeFM9H3wVhKUVR6vDlsRSZWL2eKBiwfIhGMN9cVh6MeF55Vkd75d3Hvhc39RBfWDZt/;20:kq7VvsTU4IRvxgBZRZh5KG4zlSYswhvZ8D5FhkMQIXcq1CtMnwaAUtDNnZeo4owmFLSJJUkf/tAdyZpGD7FaBO/rUg1iWezd5VRHF3N6gNDmsIMxxGeWtsQT9KLlfLDyr0KdTP7OEs3K3eyFoln1YuwwnORi+7LEGbIn+KMJh40= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 9c0bb493-96b4-4943-1607-08d59db00a66 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1014; x-ms-traffictypediagnostic: DM5PR2101MB1014: 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)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1014;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1014; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(366004)(39860400002)(39380400002)(396003)(376002)(189003)(199004)(81166006)(81156014)(478600001)(6436002)(72206003)(575784001)(8936002)(10290500003)(106356001)(99286004)(86362001)(2616005)(7736002)(2501003)(6666003)(446003)(39060400002)(476003)(8676002)(11346002)(105586002)(305945005)(5250100002)(6512007)(53936002)(68736007)(107886003)(66066001)(86612001)(2906002)(14454004)(186003)(22452003)(25786009)(4326008)(2900100001)(486006)(36756003)(6486002)(3660700001)(54906003)(26005)(3280700002)(110136005)(1076002)(10090500001)(76176011)(6506007)(97736004)(316002)(3846002)(6116002)(102836004)(5660300001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1014;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: x8nwWdZy1rjgqLTnbYMvmwH7r4VIR6dbiwx+lOCxndGeqXqnPDXLSCS4ivnxc7hWnq8N+6psVVef9ADHBd62m6kfjU/BM8VFPol4rgsMmLFXTxBQijJILTBSEqOG5JpotXxjegpe36qMzSuJ2whI2SQG32NJjcxWIGMecAhAYfzvOy0ou1zD3PpxXXmlN30wzSLhgTeyjGzpLESy3uKi9oTFmMNr78XAbXebX7kYzQYXJCc/lrzeswpvb4VwrYeZmH81rH/iiyl8Rgvpoo/caun5KnDIMD1kfIzWHD+EJh0tW8hK191aYa48FoSxYU2XYSOBeuWeFRHZnP3gtLZcg2mlhJy9T1ad3NWBfntBX3OLc0Mpyaix5+zy1haHdQbdXLIoZ5gd2PG0RX1scokio59ktVY2n1lCMAEa1PRZTPs= 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: 9c0bb493-96b4-4943-1607-08d59db00a66 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:20:24.0506 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1014 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