linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 4.14 20/30] perf probe: Avoid calling freeing routine multiple times for same pointer
Date: Fri,  2 Aug 2019 09:24:12 -0400	[thread overview]
Message-ID: <20190802132422.13963-20-sashal@kernel.org> (raw)
In-Reply-To: <20190802132422.13963-1-sashal@kernel.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

[ Upstream commit d95daf5accf4a72005daa13fbb1d1bd8709f2861 ]

When perf_add_probe_events() we call cleanup_perf_probe_events() for the
pev pointer it receives, then, as part of handling this failure the main
'perf probe' goes on and calls cleanup_params() and that will again call
cleanup_perf_probe_events()for the same pointer, so just set nevents to
zero when handling the failure of perf_add_probe_events() to avoid the
double free.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-x8qgma4g813z96dvtw9w219q@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/perf/builtin-probe.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index c0065923a525f..e1ac51aaedcff 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -712,6 +712,16 @@ __cmd_probe(int argc, const char **argv)
 
 		ret = perf_add_probe_events(params.events, params.nevents);
 		if (ret < 0) {
+
+			/*
+			 * When perf_add_probe_events() fails it calls
+			 * cleanup_perf_probe_events(pevs, npevs), i.e.
+			 * cleanup_perf_probe_events(params.events, params.nevents), which
+			 * will call clear_perf_probe_event(), so set nevents to zero
+			 * to avoid cleanup_params() to call clear_perf_probe_event() again
+			 * on the same pevs.
+			 */
+			params.nevents = 0;
 			pr_err_with_code("  Error: Failed to add events.", ret);
 			return ret;
 		}
-- 
2.20.1


  parent reply	other threads:[~2019-08-02 13:25 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-02 13:23 [PATCH AUTOSEL 4.14 01/30] netfilter: nfnetlink: avoid deadlock due to synchronous request_module Sasha Levin
2019-08-02 13:23 ` [PATCH AUTOSEL 4.14 02/30] vfio-ccw: Set pa_nr to 0 if memory allocation fails for pa_iova_pfn Sasha Levin
2019-08-02 13:23 ` [PATCH AUTOSEL 4.14 03/30] netfilter: Fix rpfilter dropping vrf packets by mistake Sasha Levin
2019-08-02 13:23 ` [PATCH AUTOSEL 4.14 04/30] netfilter: nft_hash: fix symhash with modulus one Sasha Levin
2019-08-02 13:23 ` [PATCH AUTOSEL 4.14 05/30] scripts/sphinx-pre-install: fix script for RHEL/CentOS Sasha Levin
2019-08-02 13:23 ` [PATCH AUTOSEL 4.14 06/30] iscsi_ibft: make ISCSI_IBFT dependson ACPI instead of ISCSI_IBFT_FIND Sasha Levin
2019-08-02 13:23 ` [PATCH AUTOSEL 4.14 07/30] mac80211: don't warn about CW params when not using them Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 08/30] hwmon: (nct6775) Fix register address and added missed tolerance for nct6106 Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 09/30] x86/mm: Check for pfn instead of page in vmalloc_sync_one() Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 10/30] x86/mm: Sync also unmappings in vmalloc_sync_all() Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 11/30] drm/msm: stop abusing dma_map/unmap for cache Sasha Levin
2019-08-02 18:06   ` [Freedreno] " Sean Paul
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 12/30] drm: silence variable 'conn' set but not used Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 13/30] cpufreq/pasemi: fix use-after-free in pas_cpufreq_cpu_init() Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 14/30] s390/qdio: add sanity checks to the fast-requeue path Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 15/30] ALSA: compress: Fix regression on compressed capture streams Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 16/30] ALSA: compress: Prevent bypasses of set_params Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 17/30] ALSA: compress: Don't allow paritial drain operations on capture streams Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 18/30] ALSA: compress: Be more restrictive about when a drain is allowed Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 19/30] perf tools: Fix proper buffer size for feature processing Sasha Levin
2019-08-02 13:24 ` Sasha Levin [this message]
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 21/30] drbd: dynamically allocate shash descriptor Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 22/30] ACPI/IORT: Fix off-by-one check in iort_dev_find_its_id() Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 23/30] ARM: davinci: fix sleep.S build error on ARMv4 Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 24/30] scsi: megaraid_sas: fix panic on loading firmware crashdump Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 25/30] scsi: ibmvfc: fix WARN_ON during event pool release Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 26/30] scsi: scsi_dh_alua: always use a 2 second delay before retrying RTPG Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 27/30] test_firmware: fix a memory leak bug Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 28/30] sched/fair: Don't free p->numa_faults with concurrent readers Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 29/30] tty/ldsem, locking/rwsem: Add missing ACQUIRE to read_failed sleep loop Sasha Levin
2019-08-02 13:24 ` [PATCH AUTOSEL 4.14 30/30] perf/core: Fix creating kernel counters for PMUs that override event->cpu Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190802132422.13963-20-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).