Received: by 10.192.165.148 with SMTP id m20csp566689imm; Wed, 25 Apr 2018 04:23:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx48z4EaOY7R0yasjrkKss32i4o0nbpq7lDynxG7oIDwTTTWx04N+AGeW5LmtN+Mw0ioWz3C0 X-Received: by 2002:a17:902:9349:: with SMTP id g9-v6mr28665876plp.73.1524655400970; Wed, 25 Apr 2018 04:23:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524655400; cv=none; d=google.com; s=arc-20160816; b=lQaFpR32Iohsr9RHHteyuHEkn5cTAMOp9lvaM6ebv+RXfnUnGS8sx2iJL1zY59rF9Q H2NluCxT/t+PK8AV1jt6sYMLKvHlyyG2/DRLm3PSsrfHxn2qZ3LyzHhHH7ThrCpSfl1i 75UbQ6yZ2rid0U56GDl8djK7tINVdsAoEXp+3ol7kcvA8ZOIWOrfgReGbel1Qh4AlwYa 1H2yVaH0XN3fO/L4yW2pU/K3+DGTQoXlh/rkqqr1UQq47HcP3xlHVlaKA6awfwMSZEA/ 4vss9RjjdJIHnzDntgo2lGMSgogzpqkhVTKp8bmBMSjaaKvvcv8tdkTEpa5d0BiDafu1 34XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=QfJKFDDN4OuY7EPhAthaXws1j2OFVbrxR3jWMVIuMjk=; b=Ec31bv6//gcBoBeVVL5iBc6786WOc3edyOpFTSjK9yZAFrg687ZM5XkSBb6he9JvYJ 23w4+oIapq9/+m2rJtN0XILtEk+gN9KxWoKw3dOgDVLsFfGAiZ2jNAIveq4WqrCNajVT 7tfLazbM4yEsUW/shb1mMB2a5v3CJi1XSvX2775b8AicJntOcoulZpIjfSPDO3yK5vH2 4pexvJ/3Lkn0d8avlJ40CQuWRZjgkNh4yndHlJaGphREW7fj3D/7Y3Sund++MlUf8FvM yJ31j1FTAd60G/EYq/BkosDp6fTcBUUmBdEvGgmNyCzZ6KgUWXZspDVAU0vuT7cOPwJb qyKw== ARC-Authentication-Results: i=1; mx.google.com; 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 o69si15706384pfi.322.2018.04.25.04.23.06; Wed, 25 Apr 2018 04:23:20 -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; 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 S1753611AbeDYKj1 (ORCPT + 99 others); Wed, 25 Apr 2018 06:39:27 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51848 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753592AbeDYKjX (ORCPT ); Wed, 25 Apr 2018 06:39:23 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A6627480; Wed, 25 Apr 2018 10:39:22 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ulf Magnusson , Masahiro Yamada , Sasha Levin Subject: [PATCH 4.14 059/183] kconfig: Fix automatic menu creation mem leak Date: Wed, 25 Apr 2018 12:34:39 +0200 Message-Id: <20180425103244.907393788@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ulf Magnusson [ Upstream commit ae7440ef0c8013d68c00dad6900e7cce5311bb1c ] expr_trans_compare() always allocates and returns a new expression, giving the following leak outline: ... *Allocate* basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no); ... for (menu = parent->next; menu; menu = menu->next) { ... *Copy* dep2 = expr_copy(basedep); ... *Free copy* expr_free(dep2); } *basedep lost!* Fix by freeing 'basedep' after the loop. Summary from Valgrind on 'menuconfig' (ARCH=x86) 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 Signed-off-by: Greg Kroah-Hartman --- scripts/kconfig/menu.c | 1 + 1 file changed, 1 insertion(+) --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -372,6 +372,7 @@ void menu_finalize(struct menu *parent) menu->parent = parent; last_menu = menu; } + expr_free(basedep); if (last_menu) { parent->list = parent->next; parent->next = last_menu->next;