From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D505305677 for ; Wed, 24 Jun 2026 05:15:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782278150; cv=none; b=D+ET4mmxCLbk1bSnee+1fPkzp5VQIHe6Jcepse6jyb/8NP2VXquv5b6sLh6cnFO7PB2nkDTniaTnYvaWD+cJThX0zqH9yfZDx8ZGJSKhtxXOn007ZqgbDlfVTzQZJnpI3zfAsEN6H/7IXXCX4XHlip4m4nCQE/AigjmqB30/1qU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782278150; c=relaxed/simple; bh=S6n3MCf+1noOOXyOT0egh28Ba2We0vmyA3uvN9n9H/Y=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Ad2xNJe2wvDorr0htkjeplf/MKo6z4K92bshrhWN4eXYhFNWOL4VbLTv/poj1cPPIVtwRRiD5RrCG6FYBOPWdvzqL8quUpjx7bYV9y+E1oCP2VdeUTs8K2F2Pwl2BGxzh8ZCQSRnCIiHzwgO318/lr3yfKaQP2InhYtA0P1OkyU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=WakVhBlD; arc=none smtp.client-ip=74.125.82.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="WakVhBlD" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-13980b6561dso1848581c88.1 for ; Tue, 23 Jun 2026 22:15:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782278149; x=1782882949; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=AVENzGx1t9zyrPYrTEFVcAA53+POZbJtBY/pByBi5mQ=; b=WakVhBlDx+HUpgcc4DDrWm6ctEKaPeM7I3P+2fK1nDdRiiiotYFpnCDsSV4J/VK66/ 2R4HdhfDaSbQkQU5G2znI8637kU586LL4em50eJQ0dw4Q7PQBn43wIGS489aIuwXD8TJ 9VkA3vXg/d51etI/V9yxas2fxd2JPqFx7SgHdbYlX8/RFW47WGzg3JH0ntWjszUNjiR1 g+2Q96OGLS4H1P83bhSBWlnemEVz4YdxJbqROW/p3NWgaekzzhZz1s9w8kUU3uJGwMlv TWFEgEfYCPmVQ9TDItwYkYYD7afbeB32vQyA8y9+gtlbbO1IAL5JPROH9pc9KZ4UDd1i esLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782278149; x=1782882949; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AVENzGx1t9zyrPYrTEFVcAA53+POZbJtBY/pByBi5mQ=; b=Dxl1Jc2FNVgvOr7IOLHhqDOlNc6tKK2WfWzlIbUAq3xNbKwo/um8g1e1Q8eJ/llRFj VEUbX/5wZjtU6TqJ6KiktMDSNr82n2ZwDzCsqr+IHQ7Q5CUDer4Vlrelwj3bGy2uBh/1 3zZbN3CqPlED9jx0ZVKyb36oBWNwpgSovcnUqrm3UKM5ORePFE5iwn0Om/2k35SMKy9s E891q7Q06MtCIRbkMFa6xG4fXJKI1cFFA0BU7oBtSf2X5SpUUuo+WrRLC9MtaOUEABAn uptLKRxXWKyjsqbT5U0vGKPFwyfxgfBHrHBkEtEgzZntnSD2fIqaiyqQ3s2J3ad/oH+3 +G+A== X-Forwarded-Encrypted: i=1; AFNElJ8I2LHoW5ODadUUA4B6pz5mowUlmOZAaQjUPkiU4lXqwBXHL0HteRonbOEHC3NIXdyEEa2WHf9mHaWCvlY=@vger.kernel.org X-Gm-Message-State: AOJu0YwsEZGG+WXEl2OSrxpz3v/BY8RYp+6W4vIw7qPA3AEvqqmlRo8I HYHwYigNdXEOFHj5NPN5JGqfuOxdqTEEAz7AN8WfDpO6y0ZtAlVEGEvf6gH43i28WsRM5KV6lWb yjixLO2rzNg== X-Received: from dlbsi14.prod.google.com ([2002:a05:7022:b88e:b0:136:23d8:d537]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:ef12:b0:137:ae1d:5b58 with SMTP id a92af1059eb24-139d0c89158mr1499600c88.20.1782278148344; Tue, 23 Jun 2026 22:15:48 -0700 (PDT) Date: Tue, 23 Jun 2026 22:15:21 -0700 In-Reply-To: <20260624051535.3584977-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260623053515.2677888-1-irogers@google.com> <20260624051535.3584977-1-irogers@google.com> X-Mailer: git-send-email 2.55.0.rc0.799.gd6f94ed593-goog Message-ID: <20260624051535.3584977-5-irogers@google.com> Subject: [PATCH v2 03/16] perf top: Fix sb_evlist leak From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: adrian.hunter@intel.com, alice.mei.rogers@gmail.com, dapeng1.mi@linux.intel.com, james.clark@linaro.org, leo.yan@linux.dev, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, tmricht@linux.ibm.com Content-Type: text/plain; charset="UTF-8" Fix a memory leak in cmd_top() where top.sb_evlist was not freed if evlist__add_bpf_sb_event() fails. Note that evlist__start_sb_thread() and evlist__stop_sb_thread() take ownership of the evlist and free it, so we must only free it if we fail before starting the thread. Assisted-by: Antigravity:gemini-3.1-pro Fixes: b38d85ef49cf ("perf bpf: Decouple creating the evlist from adding the SB event") Signed-off-by: Ian Rogers --- tools/perf/builtin-top.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 5933c46ee137..abc74b8ab759 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -1881,6 +1881,7 @@ int cmd_top(int argc, const char **argv) if (evlist__add_bpf_sb_event(top.sb_evlist, &host_env)) { pr_err("Couldn't ask for PERF_RECORD_BPF_EVENT side band events.\n."); status = -EINVAL; + evlist__put(top.sb_evlist); goto out_put_evlist; } } -- 2.55.0.rc0.799.gd6f94ed593-goog