Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2392711lqp; Sun, 24 Mar 2024 17:27:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWLVbGQd1lpxGfJ2MVNiRiHZFKUaMBU4mg9AhIF0vZFf/NhsyquDMRC4FsTcy1nKbzd2bfEP9Q7CkdD1UmmHI9sESxofnK0Mhre3SQU0A== X-Google-Smtp-Source: AGHT+IFk9+AT/aBHF0TjrflgUfmH/L6XvBzPmMyikg78pQEN2n/XOTlibhiBJIoBGf5xIh+a3Gsy X-Received: by 2002:a17:906:fad6:b0:a46:d786:3672 with SMTP id lu22-20020a170906fad600b00a46d7863672mr4136304ejb.13.1711326463078; Sun, 24 Mar 2024 17:27:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711326463; cv=pass; d=google.com; s=arc-20160816; b=HG7Haa7dxdC/AzEPxiUo4VOtaexQIlbAysOCnelCglZBpzDGB5R5OlBbYoEJiFKyJR Nlv+itj5LUvsro6TZiwBLGbOG1TRm4/uRAGLyFEGNOaglCHV5Rfk4QKY/fLRA8ltjmvU FG7CP39vWxyVCwfbsCt89Astjb5o/koI1Axx4rTui7kPHAOMC24/9XF+JTHRv/h/zAhJ 00i7frVkp6AfQCTf4i2Tn7NN/5qK9WHEERUEYSSdjYE5xVYDUM33vG61cHEIAL74mjFP SVwEPfzuiknNcG7jGP5LGYMYZaS7I0m6FJAhLkxEt6X9knXKi8mv6gudVC0kirYjK8p1 6Ivw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=WrPfuQI8uO7bKe9D6N4/C+Yxegcjafa8CiygxJUkpyc=; fh=W7r57cYOOYAnORoU55s7xz6zGTVorigkRzMhlmgn+As=; b=U37G63B5+C0jcXS+2XpTdyITx/1Q1fLwwfgXfSF+HZ/c3P+xQ8SxdtYkqAoMMQ3XNc 01V3hGr7BkENhBE4JAgI+hZSfTyDX5yZ1dTlABkahZ4XdJoaLA792081gzIVAZrlbSdx sHNUM5NEBPZlSm2zpJf6dRtk0eQd7E97gAucqggO24tG+fg3fDO7xBW4s0L7G26QIfYJ njMHi930BpI4wKPovL7BBI6AhysOe358FxpRXLk8gIOmR4tPjTEQJZmGMCE1ddS2S8h2 tK9BfCigWluLkwYj+h3l4jif01ezQM/zt5InWhkzKGYEshfZ4q7/e/7rTREKgumUejol AIMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GrNrPf+N; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113376-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113376-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m10-20020a17090607ca00b00a45b8c249c8si1971447ejc.1027.2024.03.24.17.27.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:27:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113376-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GrNrPf+N; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113376-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113376-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 61D781F2659C for ; Mon, 25 Mar 2024 00:21:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E7DD019F52A; Sun, 24 Mar 2024 22:42:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GrNrPf+N" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E644E19F501; Sun, 24 Mar 2024 22:42:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320178; cv=none; b=qwo4I0+ftczx8lsjuE4G5og9MdkIMSYJDKtku9Dg1mbhuAi9dGZgeCAveyX4XpHkjtSmzGzp0kGlvHPBvDtsA0yE8jjBlu0VtRbEMOViNn9L1RBhcX5vcM+6fDAKK/+4/Rz665dbIXX0w38B7gNrsx1CXRPuNpEo/NuQjWgF8iQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320178; c=relaxed/simple; bh=4R1K5XCsgWuPw6D5zIv86PhgnTtk3Z9jomPfPWJlF9k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S70vOJ1hQBk8iXze55/EoU7LLOVpyGpszywEy1WQxsMVhctpRx7NGX/6xfpMJm8MOITdv3NOiCsIaAO3Um4MRxOTlDGhxLPkdryC9d8O0fdDHPFKfA+c5g+Y6RX6KAntCoi0+qtycIQbv0MQcLI07Y8M3Uj2JRnJPKVm5sOgiRw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GrNrPf+N; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A038AC43394; Sun, 24 Mar 2024 22:42:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320177; bh=4R1K5XCsgWuPw6D5zIv86PhgnTtk3Z9jomPfPWJlF9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GrNrPf+Nvh54K+Eu6Z/Rz5tP4Br3AfUZwNGUhHD/f9UIZHCh0l29TaIvE9/2zPhcy PTG5VbQeTnlrHY24g1J1b8siFyf5DCZBMnStcyygIF2GvgoN4kZJrSOFyEmG0Z2eFD O6H4HxiikJL+7RZdBEKQpRTaPsxrwn26Uw7MG/OrgW60sG/18IrL1VAzGAPhucbGoe wHBfNvD9WiBZ/b1kSa35G90LTCiqrdHez0ZgjmOLCiazVl+2r01Vqt1JSxWjkk+rqh XD6EkQrE9lk9G/8J+PzJISCorukqutU8pEzcZ2KaIkJqytyJDKPqfBWNn4ssWRixGU f9GB9/MlSJcwQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christophe JAILLET , Ian Rogers , kernel-janitors@vger.kernel.org, Namhyung Kim , Sasha Levin Subject: [PATCH 6.8 485/715] perf pmu: Fix a potential memory leak in perf_pmu__lookup() Date: Sun, 24 Mar 2024 18:31:04 -0400 Message-ID: <20240324223455.1342824-486-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Christophe JAILLET [ Upstream commit ef5de1613d7d92bdc975e6beb34bb0fa94f34078 ] The commit in Fixes has reordered some code, but missed an error handling path. 'goto err' now, in order to avoid a memory leak in case of error. Fixes: f63a536f03a2 ("perf pmu: Merge JSON events with sysfs at load time") Signed-off-by: Christophe JAILLET Reviewed-by: Ian Rogers Cc: kernel-janitors@vger.kernel.org Signed-off-by: Namhyung Kim Link: https://lore.kernel.org/r/9538b2b634894c33168dfe9d848d4df31fd4d801.1693085544.git.christophe.jaillet@wanadoo.fr Signed-off-by: Sasha Levin --- tools/perf/util/pmu.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 88b9aa7d3a27a..6b82f4759ce69 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -1019,10 +1019,9 @@ struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char * type value and format definitions. Load both right * now. */ - if (pmu_format(pmu, dirfd, name)) { - free(pmu); - return NULL; - } + if (pmu_format(pmu, dirfd, name)) + goto err; + pmu->is_core = is_pmu_core(name); pmu->cpus = pmu_cpumask(dirfd, name, pmu->is_core); -- 2.43.0