From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.197 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796346309; b=Dzu9D0GTnO4EddrYbQs2Vh5fItA/rg6gsbgQs40Gw5lPV60/Da36g4ftLCAsWJfG6eHC oqrC+ugKyKZRZ8tILhz+CWZfY553bUZTwUZL5stLyACd/oeAYbKo44Emgw8a+VzMnEodT HW3lxgRNW0n2ctGTNL1xYQIkWxLLJraoscLnU5xgzEHIstfXwk2fpzDb2n+Q+3VmNXVKC 4RemMZpMWQJgSplEmFU7RrBjuFlWXLVTF3phZNJFnWkgnw3O+1NeXTeK3K3HxERVkYZEa x0KnDmy/DVaPdmR2+odPeVstW1NGx2JZaB3w/jGLvjKluHgDbAVI3KDT9/XErf9Vj/Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796346309; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Received:Date:In-Reply-To:Mime-Version: References:X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=mG1XqTBObVXpG7DaFld2gZrerl8g5dXOvv8J3bs2ytU=; b=Wfq9ooQRAUgG/slAAX5+5ccY41c1I0C9J3KyL/dzwN87N1CqM9kOwiLtN0y+3ajDvtMk fLoGmbOXpqjzj3NiBSlulZY3NOwpio0GOLdoPkCrx8uLzIdUE07L6sf8f6kXvGAffaQ2y PyF3K0uTzd2u+PG+QgIvyGhRm3IiG1Ax8tMA0/wwFFnd/yiBRhzcAAzTasu+nT1NknuA4 b1Mo8o1ioKURsOXdV3X+ukPV1KpjE4pvS+y+AAUBe4V0JEXQau9hb1XiPNoKnfLtPqZ7n qP6mHF2XxLP/xipT3ipcdecVwX6rKYpW/1AuX4wRKFiDw8scAA6ApSM3Thm6eHX55rg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=IswFb5y5; arc=none smtp.remote-ip=74.125.82.197 Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3DE5606A681 for ; Fri, 4 Dec 2026 01:05:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F3DE5606A681 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.a=rsa-sha256 header.s=20260707 header.b=IswFb5y5 Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-386a65fca25so740656eec.0 for ; Thu, 03 Dec 2026 17:05:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796346308; x=1796951108; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=mG1XqTBObVXpG7DaFld2gZrerl8g5dXOvv8J3bs2ytU=; b=IswFb5y5oP6KVuiS4SWWPDb+mWM59O6Ruxl56KYwP9idr1zSgcl/oy5bhdE226gu8r pnL0HWC/uaLtpDshayhlpPgEFJ1I+euMPuLi0lmuvmTC2/faEUSsnPG6LcMKONYXTswq yNm2Ghiqx0pOubGXRMcb2XHvD295PALBKBwtcyvao8UgYflmNIqlj33UjWPHPJ1UgZbt zqlg3FrL0oGLIns5SJ5orQXCXRUKcKVvwZZkZYvQjbxc2lqlIiHmMa142kvTgfe9Mm77 y0VqYPx7gUKsHiKoOV+wdh6AsMQhPtWtV/Nsydor10v0Aco3IfGG0x6+hROGVI01D77/ I6AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796346308; x=1796951108; h=content-type: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:content-type; bh=mG1XqTBObVXpG7DaFld2gZrerl8g5dXOvv8J3bs2ytU=; b=SnQFM/YClSiYmUl3AALYpFOuP+2uOfOwTAUt9wr//+09L+o2yGg776vTeFyoSlYEiH h0yoQP14ALEnBF0YmAMLyWVtQk/bJJioGR5l7qjbandT0ggh2tgwcuRcnv45IvdXEMFy fJWIewO9D8DR4v/AOfOSZYxO1rbw440keuWPz1j/nUPR+4ObQ2PJznK0ivFk+RqLYp5B ThdBxv3YcGJMU9xvkkgiQgiutI2uktpDRzJpudNdPAsdEClbf2opO3/da4/10hmmqN3V BYw6BpaZjRUbBP0c72O/g4nenzeg82v4AHSC4O4Eff6BZ7YmMo+5tOC7CB0Gjt6em2pA AoIg== X-Gm-Message-State: APuU4Z+J8zK4zpxcT1i0zBSktQNvGwPMb0MSRG2iWMT/uY3DxEVC2UKs 2UU7LDokPyaF5epY9lnFjhPrcFkYmr08X68PRFsTtaJmZWRhd0kOsaKxNnHMfCPswvznbwLyLJm 91krVxsIG+pUDRmHZjgeoWMOqYwLsavsSzff9VeeezdhmFZhoimrM5fhhsBwDTq3oPL6nlEjmOH jBQWoacmJSA4oxTZSYHK2QoYztLaR19TIPGWBTcqbedqrBriYCIPXSxRs= X-Received: from dyp6.prod.google.com ([2002:a05:693c:65c6:b0:380:c63f:6b75]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:d0b0:b0:387:5482:9e1d with SMTP id 5a478bee46e88-3875482a737mr10649eec.36.1796346307492; Thu, 03 Dec 2026 17:05:07 -0800 (PST) Date: Thu, 3 Dec 2026 17:04:46 -0800 In-Reply-To: <20261204010452.1937224-1-irogers@google.com> X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261204010452.1937224-1-irogers@google.com> X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog Message-ID: <20261204010452.1937224-2-irogers@google.com> Subject: [PATCH 1/6] perf machine: Fix leak when creating host kernel maps fails From: Ian Rogers To: linux-perf-users@vger.kernel.org, acme@kernel.org, namhyung@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, jolsa@kernel.org, adrian.hunter@intel.com, james.clark@linaro.org, dsahern@gmail.com, andrii@kernel.org, Ian Rogers Content-Type: text/plain; charset="UTF-8" If machine__create_kernel_maps() fails in __machine__new_host() the machine is freed with free(), leaking what machine__init() and the partially created kernel maps allocated, such as the kmaps, root_dir, mmap_name, kernel DSO and threads. Use machine__delete() to release them. Fixes: 8fb598e5a3b0 ("perf trace: Fix comm resolution when reading events from file") Signed-off-by: Ian Rogers --- Notes: The leak was found by the Sashiko AI review tool when reviewing an earlier version of this series. This change was developed with the help of an AI coding assistant (Gemini in Jetski), which wrote the initial code, tests and changelog; it was reviewed, built and tested by the author. tools/perf/util/machine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 2750d507aecc..5fbc5941a2bc 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -144,7 +144,7 @@ static struct machine *__machine__new_host(struct perf_env *host_env, bool kerne } if (kernel_maps && machine__create_kernel_maps(machine) < 0) { - free(machine); + machine__delete(machine); return NULL; } machine->env = host_env; base-commit: 22f7d78dc87e43ff4f7c03d23f46f49692c41ad0 -- 2.56.1.915.g69d5ec7298-goog