From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796417942; b=Vhez64qwLNnMzx2/CpgSTWNWtSFd0OZ3Re2xYdxIJNK3ivapiNIMuQU54ZjEGuDA5H9T 6uDaMJLJO3Hiz30gcQ7gPrcflyJVehmQXgsj0GSuE/xabhsT155YOmiHiiu6RGzL006sB IjEMfUG9mijT1c2CuDjVBfN4ztXwkiIXl5Sb11HmFuKXszbaDEaN+i9Yo7PykgW9BZHlf zxlb6l9FOyV5PX31+c2cERu2wsOsCKxslLPW9Ut/Xc+/eyZE7snQSiGyk23DkHlGpEWqq g3kvtZyKWmx9/ahCURch37P3e5maA5jKs91GUGhmMjtr5PePU7nJ/lqbA4ikRgO+9TA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796417942; 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=ABXlZSN9FvIxEM3kJZW0lAJm3Jov8qSy58r/YUWoR3U=; b=UITySFEhCK3ka7aU8GKDHMGvKNvFJu4VBNDOj9Nu9NVBVBuYhW58DtxHC1aVoS8KCDru 4hBdP8DulE+UZMQCNulaZGG5TBMlnY8IrK0JhDbja/VdvBQPGEZdyAS5mixwCdJ/3YHay acxEvP46s8EJ48+LEic7lMtr1vTx3R19txbaru9FAPaMC7MiaiqpO3RAqceyyrEST4Bit BsEkTt6PJmaDxCziKknj1ctg1xparyGNnkhYxXuQapPEg2x1Z+yBl/4BfAv0eQ+yPzP7Q 5aEOA1fhLUL+rLT3WechzaeGipM2COICKw8Ytv28Kk+WHvEg3HYCUpGieIDC8x+O2Qw== 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=WeOqZNGZ; arc=none smtp.remote-ip=74.125.82.70 Received: from mail-dl1-f70.google.com (mail-dl1-f70.google.com [74.125.82.70]) (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 851DE606A33B for ; Fri, 4 Dec 2026 20:59:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 851DE606A33B 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=WeOqZNGZ Received: by mail-dl1-f70.google.com with SMTP id a92af1059eb24-1b5d6036854so3972801c88.1 for ; Fri, 04 Dec 2026 12:59:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796417942; x=1797022742; 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=ABXlZSN9FvIxEM3kJZW0lAJm3Jov8qSy58r/YUWoR3U=; b=WeOqZNGZHHtAUf2qIvcAPoNlaVGXQHtjrohC5Vdc6M5AnTN0t/9hWZHhQeADcKuQQ1 Yg8d1JGFhFrSdhmnmpel2S/lcT05jU/iLaO/NsIRZql/V3LocvfE2sX+Is+1Bid71lCE sYylScXqGyDYHe8uu+uT9Fl7F6IU/2uAUM6IgLILFIsJpPbLpv94rVwOLXuYKEx13FyG fIt2tnh4sqVKNWwSg5JMnG8pgL5psI9HY7rag9udwoG10gC2+z5uk0RJaM9bFdBtugQM nqtEgTRYlBYAS6xE609vENNaGkLr76QmK6Ns4Rz1PUhXuiDYT3lDLsBe47E9yOYqFDrc I9dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796417942; x=1797022742; 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=ABXlZSN9FvIxEM3kJZW0lAJm3Jov8qSy58r/YUWoR3U=; b=Li49lQn/+nKq7uIpHr/6vXDMhy1fsglMb0bkqHMLsxbNfBe3FNvUX6cGq5f9+9+100 eaeyOrX4mtgK31YfxNiw5anUCD4DzjKp3DejIIfd8gDxCkTpdUrXkAM6FM390iUAJX+N iYb31ogOT7LXiGgJVhk5oGNbCdttOXc/VOyDsfC7WkeMQwcnyf9lfh+cRVMjiflgZRZi AL26hUsqn9LnmxarB3VegZJO2+fvhGfDvcOyt1qpRylt9CJ6sfc1nJrgCOhndIvbZr0R 12U1OHyKf2HP0S+Wtz6zToHSZQo/Cx8Xw8s/3jD2v4GHC5RWKyOIz8JTZ4is2p2KDkVp cdKA== X-Gm-Message-State: APuU4Z+pGaDTSaKgWFTE8ztk6rdtP4URaKlOhMOk9h93XZ+DgDcGPyj2 zf8KRsGSOXNmOsWyKC7dz+3qAg1ijV+it49t/AF+OHrP8+I4CCzCpC2GMujL8gmjsRM1trqmJCU 59hJiPDi0Lg== X-Received: from dlbur20.prod.google.com ([2002:a05:7022:ea54:b0:1b3:af3d:1632]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:281:10b0:1b5:888a:a1a7 with SMTP id a92af1059eb24-1b5d7104e7bmr2796624c88.19.1796417941366; Fri, 04 Dec 2026 12:59:01 -0800 (PST) Date: Fri, 4 Dec 2026 12:58:47 -0800 In-Reply-To: <20261204205854.3973609-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: <20261204205854.3973609-1-irogers@google.com> X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog Message-ID: <20261204205854.3973609-2-irogers@google.com> Subject: [PATCH v4 1/7] perf machine: Fix leak when creating host kernel maps fails From: Ian Rogers To: linux-perf-users@vger.kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, 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. 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; -- 2.56.1.915.g69d5ec7298-goog