Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4420738pxv; Tue, 27 Jul 2021 07:02:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8Q+uLHBd8vLJ25MObR0Sq56FhsPQ8giZW+GVrjpXFeKboO7+/qhdp11yb5ECuAt/hig50 X-Received: by 2002:a05:6602:2814:: with SMTP id d20mr18937394ioe.65.1627394553989; Tue, 27 Jul 2021 07:02:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627394553; cv=none; d=google.com; s=arc-20160816; b=XMBXYuWCPlGfxADVnEvguYAh08f9QuYe3mJnmher2uiyfad7bewdt0od16/2Q+36lO LDmNr85naXb+e92X+iT7DMgdKdhVprjM7uhfDLARpIpQItyDyY+gfrlf+TanfMut8Hpy SF0Sjz+yY6nLULwVWDEMwIykeuJjAhWgi2MiMlHJwP/280mjZLlAj3nIjJpDJogh7Fs0 yMkaiq9Vdyq246wlGYxIIDJ+Ky5hZoVsR9h5pOYv2ePgPmWUai9Y1kmedQ9M2zzeD0n/ X402dVOXXm7KZfhVkRt/L4jOcgrJPsu4IgIIQX6B6XsHjfdO+HzrcE/lU+wJFOeZgRuZ Tiyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=Y2nR+5jMfkCJTHfxk2uZxnrbhPjucYhJrPlcEnost6Y=; b=lSAeBua7M4jcWC6ik5hCKuLRv6vyDbudgM2GE2NUijhh+aH22rWO6cruyKtonePbqY PcM3gRoBLqVFfO/m5k2cGiYlF37p5eImi/ICvmtSlkfA8r3cG21UepMCtwRK3GNqcPJW xW20xbeDxQQl6TjNBSOleKsZ6pecUUJoAoXdDMKYrCSspMsz4q7Y01rvM3VlpXcUx6tE ue9GShIkpCeZngG1uF7LOy5H5KjVN5Yl1phZ2pRRMq43cBlwxEfdNmQcdLJwqnr2Ghpo cUiZ3TfqqPV2J7VQMD3rn2DbyQgYBTbC4ZY0XXyOsaJ+lP5rVQ+j+ZiQDt+vGyIPZlK+ asfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WqGd4+t0; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w23si3278101ioa.16.2021.07.27.07.02.11; Tue, 27 Jul 2021 07:02:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WqGd4+t0; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236776AbhG0N71 (ORCPT + 99 others); Tue, 27 Jul 2021 09:59:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236672AbhG0N65 (ORCPT ); Tue, 27 Jul 2021 09:58:57 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31135C061764; Tue, 27 Jul 2021 06:58:57 -0700 (PDT) Date: Tue, 27 Jul 2021 13:58:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1627394335; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y2nR+5jMfkCJTHfxk2uZxnrbhPjucYhJrPlcEnost6Y=; b=WqGd4+t0om6tc9QtCtcwmZwwCmxvRdqeGFti+Z/9AOVMyE5J0z6JqRLEq2en2zHE7x6vOp AQUb6HY1GBBgeRnCh7u7zFKt8IE68oyQXoA/lr4kf1/rVwzepKVOMPD6VPs6LIFgtJSV3e NNcIY02Z0l7RMnV07GfrMKFMdYGcb74V5j7KW3w4axQhA23tcK2X4jKL/1j8hoiD/okj6F DwnC7awRJ+LvCebN1rP9iDGziR63txIg2wYR3v3Pi1WzXkD3ZBTS5X7teY8DaBa47Qlyge T5/2TiWSp9n0JkSKA4upPSntHBs7a3jkKwHEMJIfZh1Iy73/hg/iZx6obFP7OQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1627394335; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y2nR+5jMfkCJTHfxk2uZxnrbhPjucYhJrPlcEnost6Y=; b=RHWKnyvOhMJYFNl6YGztLDEQ/g5gEfwqVJWVTfyWS2gyGCjULaou3+ASBJVUHB+nGk2kAL PeNgPvGYvbjozDDg== From: "tip-bot2 for Alexander Antonov" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/x86/intel/uncore: Fix IIO cleanup mapping procedure for SNR/ICX Cc: Alexander Antonov , "Peter Zijlstra (Intel)" , Kan Liang , stable@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20210706090723.41850-1-alexander.antonov@linux.intel.com> References: <20210706090723.41850-1-alexander.antonov@linux.intel.com> MIME-Version: 1.0 Message-ID: <162739433514.395.10272219341326813838.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: 3f2cbe3810a60111a33f5f6267bd5a237b826fc9 Gitweb: https://git.kernel.org/tip/3f2cbe3810a60111a33f5f6267bd5a237b826fc9 Author: Alexander Antonov AuthorDate: Tue, 06 Jul 2021 12:07:23 +03:00 Committer: Peter Zijlstra CommitterDate: Fri, 16 Jul 2021 18:46:48 +02:00 perf/x86/intel/uncore: Fix IIO cleanup mapping procedure for SNR/ICX skx_iio_cleanup_mapping() is re-used for snr and icx, but in those cases it fails to use the appropriate XXX_iio_mapping_group and as such fails to free previously allocated resources, leading to memory leaks. Fixes: 10337e95e04c ("perf/x86/intel/uncore: Enable I/O stacks to IIO PMON mapping on ICX") Signed-off-by: Alexander Antonov [peterz: Changelog] Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Kan Liang Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20210706090723.41850-1-alexander.antonov@linux.intel.com --- arch/x86/events/intel/uncore_snbep.c | 40 ++++++++++++++++++--------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index 2558e26..f665b16 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -3847,26 +3847,32 @@ clear_attr_update: return ret; } -static int skx_iio_set_mapping(struct intel_uncore_type *type) -{ - return pmu_iio_set_mapping(type, &skx_iio_mapping_group); -} - -static void skx_iio_cleanup_mapping(struct intel_uncore_type *type) +static void +pmu_iio_cleanup_mapping(struct intel_uncore_type *type, struct attribute_group *ag) { - struct attribute **attr = skx_iio_mapping_group.attrs; + struct attribute **attr = ag->attrs; if (!attr) return; for (; *attr; attr++) kfree((*attr)->name); - kfree(attr_to_ext_attr(*skx_iio_mapping_group.attrs)); - kfree(skx_iio_mapping_group.attrs); - skx_iio_mapping_group.attrs = NULL; + kfree(attr_to_ext_attr(*ag->attrs)); + kfree(ag->attrs); + ag->attrs = NULL; kfree(type->topology); } +static int skx_iio_set_mapping(struct intel_uncore_type *type) +{ + return pmu_iio_set_mapping(type, &skx_iio_mapping_group); +} + +static void skx_iio_cleanup_mapping(struct intel_uncore_type *type) +{ + pmu_iio_cleanup_mapping(type, &skx_iio_mapping_group); +} + static struct intel_uncore_type skx_uncore_iio = { .name = "iio", .num_counters = 4, @@ -4510,6 +4516,11 @@ static int snr_iio_set_mapping(struct intel_uncore_type *type) return pmu_iio_set_mapping(type, &snr_iio_mapping_group); } +static void snr_iio_cleanup_mapping(struct intel_uncore_type *type) +{ + pmu_iio_cleanup_mapping(type, &snr_iio_mapping_group); +} + static struct intel_uncore_type snr_uncore_iio = { .name = "iio", .num_counters = 4, @@ -4526,7 +4537,7 @@ static struct intel_uncore_type snr_uncore_iio = { .attr_update = snr_iio_attr_update, .get_topology = snr_iio_get_topology, .set_mapping = snr_iio_set_mapping, - .cleanup_mapping = skx_iio_cleanup_mapping, + .cleanup_mapping = snr_iio_cleanup_mapping, }; static struct intel_uncore_type snr_uncore_irp = { @@ -5113,6 +5124,11 @@ static int icx_iio_set_mapping(struct intel_uncore_type *type) return pmu_iio_set_mapping(type, &icx_iio_mapping_group); } +static void icx_iio_cleanup_mapping(struct intel_uncore_type *type) +{ + pmu_iio_cleanup_mapping(type, &icx_iio_mapping_group); +} + static struct intel_uncore_type icx_uncore_iio = { .name = "iio", .num_counters = 4, @@ -5130,7 +5146,7 @@ static struct intel_uncore_type icx_uncore_iio = { .attr_update = icx_iio_attr_update, .get_topology = icx_iio_get_topology, .set_mapping = icx_iio_set_mapping, - .cleanup_mapping = skx_iio_cleanup_mapping, + .cleanup_mapping = icx_iio_cleanup_mapping, }; static struct intel_uncore_type icx_uncore_irp = {