Received: by 10.223.176.5 with SMTP id f5csp947169wra; Sat, 3 Feb 2018 14:10:29 -0800 (PST) X-Google-Smtp-Source: AH8x225+4I5ul8OgVd2VvohVFFRCf6TmbBhzdxN4YMxxYSq8xhl31Wek5VFrLEwu5hXyrJQsMq5n X-Received: by 10.99.8.198 with SMTP id 189mr1465025pgi.88.1517695829472; Sat, 03 Feb 2018 14:10:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517695829; cv=none; d=google.com; s=arc-20160816; b=FWhqhgLBEo7JYeysZjv98MwJwqODeQxxmM11K2gaSwYoW5fmuY90GGncWvohNtejMi XRf2x3zt2ieMRAIejc4gOejRBHZOSDx7+JL57bSqZpo7167RafgUoLSLmU33N2jHh4Lb zm+xbhQg9LgJFBH4fcnJ84TLWqdIVH/ZuPF0uV+qcDwI4hHdIWtR+vflYCnAspY7iOZO ViXgHi92XRloy6Yju8bUbfICNggRZFEWpDdzzkJ7pDjRB4qf9HJra5mSryCrRJFXG1kl tQbqzX9FEUZeTDLyX62qOOsy/bZ1IF5GX+gkTrh7+t22m1lQPrF7nZ+2zBX36gDac2AC fDbA== 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=CPdBw+YjCpprJbFMrrmI3/8Pbb0jeWUCJHqwyUJjTLY=; b=m35IJ88OGwLxqB4oZlFD51u9CXrx3687VxVGW7SsEHcEH60R+YUu1hBnevlzWLlKsj DZAZWn3GfBu8Ty90uRZEujexIjjZEsGnBZWJzz5P78WVrGMHryEjgNibILmRfgJAUXJv 3TFdcD9fpNV7dGXQNVY5EqS59Z3kGplYhhwCvkQz3QJ8qg0qcXeEFQyZeCSCuSHWACQu piBLWrL+BjTqSA90GkEDAjGynKcLtX17OdVchCMD7IBLIWTiTaAPvNP0RFboP1XWGL/R 3+MhY6VUmbwgc4DUOIRg3Pd3hUvubb1oQq0wkeVTDFa/LoKpXV0yaFZaFG/rIZNGfToy 6UdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=V4w7znn+; 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 k192si3445655pgc.299.2018.02.03.14.10.14; Sat, 03 Feb 2018 14:10:29 -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=@microsoft.com header.s=selector1 header.b=V4w7znn+; 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 S1755172AbeBCSpl (ORCPT + 99 others); Sat, 3 Feb 2018 13:45:41 -0500 Received: from mail-by2nam03on0136.outbound.protection.outlook.com ([104.47.42.136]:45129 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753156AbeBCSCx (ORCPT ); Sat, 3 Feb 2018 13:02:53 -0500 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=CPdBw+YjCpprJbFMrrmI3/8Pbb0jeWUCJHqwyUJjTLY=; b=V4w7znn+MsxTp+mC7BeDCoNnYOKODdX67woUJD0EZYPad7svjoN5yl/I1elIJrJzcTlwGdYpsPuXayH9xw55dZPSOtJRtQO9fnmyjhj2XWsfrTPntRfwF+H3MiaieLozSh6BZs9LfOuLmozez00T0CuZg1f41wkSooXP+aUkZ4M= Received: from BL0PR2101MB1027.namprd21.prod.outlook.com (52.132.20.161) by BL0PR2101MB1105.namprd21.prod.outlook.com (52.132.24.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.485.5; Sat, 3 Feb 2018 18:02:04 +0000 Received: from BL0PR2101MB1027.namprd21.prod.outlook.com ([fe80::a8da:b5d9:d710:9bf9]) by BL0PR2101MB1027.namprd21.prod.outlook.com ([fe80::a8da:b5d9:d710:9bf9%3]) with mapi id 15.20.0485.006; Sat, 3 Feb 2018 18:02:03 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Thomas Gleixner , Andi Kleen , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 064/110] perf/x86/intel: Plug memory leak in intel_pmu_init() Thread-Topic: [PATCH AUTOSEL for 4.14 064/110] perf/x86/intel: Plug memory leak in intel_pmu_init() Thread-Index: AQHTnRjylMzI0D/X0kCyRlSe/K+0mw== Date: Sat, 3 Feb 2018 18:00:59 +0000 Message-ID: <20180203180015.29073-64-alexander.levin@microsoft.com> References: <20180203180015.29073-1-alexander.levin@microsoft.com> In-Reply-To: <20180203180015.29073-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;BL0PR2101MB1105;7:LaK0fG+3eCdmKPjwv2F+irijTRbfkcgjKCpMbnGMMntB7DaoCRkm7OX1j+OAcm9/7NTouQt84TV2JMa5n88MjzukqDWFpM8I5QmT4G+4eA7+CTeeb3wvo6W/n8S5i2l39kp+YvEjM+rBCEgMKVfed0beF4QW67qBse1HOPsXkY/LR2iLp31PSljIqznaEN/zJycWc1mT7rbMKtCD1rMaZP6tzzf3chwUPMLJom2BBP8RRfbQskKnxrWDxoB1l5Dp x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 992ca31c-302a-4b60-2ee5-08d56b303b44 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:BL0PR2101MB1105; x-ms-traffictypediagnostic: BL0PR2101MB1105: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(82608151540597)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231101)(2400082)(944501161)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:BL0PR2101MB1105;BCL:0;PCL:0;RULEID:;SRVR:BL0PR2101MB1105; x-forefront-prvs: 05724A8921 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(396003)(39380400002)(39860400002)(346002)(376002)(199004)(189003)(6346003)(97736004)(6512007)(7736002)(26005)(305945005)(102836004)(105586002)(68736007)(5250100002)(8936002)(59450400001)(6486002)(6436002)(106356001)(6506007)(81166006)(81156014)(2501003)(2906002)(10090500001)(99286004)(66066001)(54906003)(6116002)(3846002)(36756003)(1076002)(8676002)(110136005)(575784001)(107886003)(72206003)(2950100002)(478600001)(10290500003)(22452003)(6666003)(5660300001)(2900100001)(4326008)(25786009)(14454004)(316002)(86362001)(53936002)(3280700002)(186003)(3660700001)(76176011)(86612001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:BL0PR2101MB1105;H:BL0PR2101MB1027.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: w7P26hniqX00MOPdQh9wKP3tecIrhh84tYRF/Wf9Qf1TYef5quKxz+I6CRHQGRKzj1A9ZkqZojGzWdqYtttVGQ== 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: 992ca31c-302a-4b60-2ee5-08d56b303b44 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Feb 2018 18:00:59.1440 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR2101MB1105 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner [ Upstream commit 7ad1437d6ace0e450a6c1167720608ad660b191d ] A recent commit introduced an extra merge_attr() call in the skylake branch, which causes a memory leak. Store the pointer to the extra allocated memory and free it at the end of the function. Fixes: a5df70c354c2 ("perf/x86: Only show format attributes when supported"= ) Reported-by: Tommi Rantala Signed-off-by: Thomas Gleixner Cc: Andi Kleen Signed-off-by: Sasha Levin --- arch/x86/events/intel/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index 09c26a4f139c..731153a4681e 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -3847,6 +3847,8 @@ static struct attribute *intel_pmu_attrs[] =3D { =20 __init int intel_pmu_init(void) { + struct attribute **extra_attr =3D NULL; + struct attribute **to_free =3D NULL; union cpuid10_edx edx; union cpuid10_eax eax; union cpuid10_ebx ebx; @@ -3854,7 +3856,6 @@ __init int intel_pmu_init(void) unsigned int unused; struct extra_reg *er; int version, i; - struct attribute **extra_attr =3D NULL; char *name; =20 if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) { @@ -4294,6 +4295,7 @@ __init int intel_pmu_init(void) extra_attr =3D boot_cpu_has(X86_FEATURE_RTM) ? hsw_format_attr : nhm_format_attr; extra_attr =3D merge_attr(extra_attr, skl_format_attr); + to_free =3D extra_attr; x86_pmu.cpu_events =3D get_hsw_events_attrs(); intel_pmu_pebs_data_source_skl( boot_cpu_data.x86_model =3D=3D INTEL_FAM6_SKYLAKE_X); @@ -4401,6 +4403,7 @@ __init int intel_pmu_init(void) pr_cont("full-width counters, "); } =20 + kfree(to_free); return 0; } =20 --=20 2.11.0