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=aCYE9FIlCt1+08RyCPwIVm02eawmXgmRcnrMdqjtbrScmmFcvliydM3T1iLIl3R7vgYT 34UScCYsCJ8B2JuE2njW42CW7pawXrG/0r5lIY6MWpncSvCfJq5xPKngs4z3fiBNou6Wx FzdE8FJn0ad1spk9kojJmJ6ly022jXPKETzbUOZ/47WeI54mVPHtq6HBpEYGtBarj9K7+ pONEvm/ixHz8N+a6nmE5RRCKUcEWgYNQcqdgb3+GYzUb3IBh4k2t/pfP+2YO3OJX0EaP3 Uw1CJwY6VcRAG+1kVqUviD4H4DWiKVAAM/mebtvD5CwpbOIlFFd7EVCL+uux2f5Bq8w== 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=sgllsBR/WXoi1R4EiWOOgsSUlgEra5Nm+31TkXj/pBURUoUdn2/QE9Ws+jCMht4C82xy NU0S0/AEzFVfjpJsmtTN0aqdv5o4IgFQ/s+/fNM4EHlsfSRCy4RQHAsx1oKWnEF/Czo8h w51muObvCwD+DBSIvaR+UUf4r74+E0qKCKksWqoNPlPWLOinQkDWCpe5ohLU8dD0jsz+3 KAeWYXuQ3cSa86WgdCIpVThonp5ezrYgdP8Onf9aFDzwmiUARe7WVMf4U9sDVU2+j3gcl j9EehJoV54Dz/v5+2ZqqF84OUY59mUp5oaKqf2ou3ZhwFG4/QofoRCNZ1qOfr7hrw9w== 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 C6E5D606A680 for ; Fri, 4 Dec 2026 01:05:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C6E5D606A680 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-386a65fca25so740639eec.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=Oajz03kBRi83x1NQxpr6YjMiqdtblvvg0wsMk2w053JSVxVSnCS3At6mqLGli9j3hF WHCSwqgUBOg4y0olQKizuPoLkOE2G6X5/D186Z4zXdJoxI8p72yo3AYSUyMU5NxUw7Dt Cis9FxVsq7LDkjT0Tw/wjAoXrPpNsn2tCdP6ZRFBeN4aZXrp3uGo1OK0n4bEypl37CoY SJWnlnsYmXXxiMN7sskzQSpi3cZyifOsrkKpMs/c9SuzWruDtw4xIH5lXIkKj4DRHoxt SvCQUs3lQyW4wlZg0vj7zR9zweaNcgV9QOgDY99DbVrU+UlbQE5987b2jmuOdn0w7a/4 +//A== X-Gm-Message-State: APuU4Z+1sopfBkdlbmYotW28sjnxuD2j13PIBkucABfY4UdU77HWne0q r3JIODkjHvkoNxj+ToHvGeMUYU5AbTVEgZtuDk/DW8exgGKxtuPHeY/cj3ZvWigQdADyNfzgxFb zTqDZ96CUjQ== 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-kernel@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