Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp756782lqo; Fri, 10 May 2024 14:05:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWVKiMPSPbyE3bnC0oN5DAzaKvuz2fXNg5/fNbWRC/NGEPDBQhVM3UmyBIGV8kejrjzV54PGSYt7qL+8yAiyU6/lhTmvMl42e3rTTfX5g== X-Google-Smtp-Source: AGHT+IHPowFKlcMtxshoyr4ijScL3PeLbvE56sloNJhMYpFzsQnx8HfZbwefLi0+5ddBfptUV0Em X-Received: by 2002:a05:6a21:78a4:b0:1af:41d1:732e with SMTP id adf61e73a8af0-1afde1c4cf7mr4524367637.46.1715375148751; Fri, 10 May 2024 14:05:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715375148; cv=pass; d=google.com; s=arc-20160816; b=IU8hyIUG/WhGBdF6TsH/fUayGwjmyE3pvXNvnsqCui5TB9cZ27w0JxtsNwIINq/f+p ommeGfo7ZMjncHB4tu7QphZ8InU8CKyb7r+p2eA5q0uBMJfnkPvwlt+w+/voGTP7sVsh 3zdYR7nGhF1tkyc2ySiOmxOZ3grI3XdWQnGO+X4qSPJUu/+3iTk43TQlaAJLp1nPZDJV 3UC+6oI1RaBo5pTm7iarECorPNHiisDYmOPCTn3RLhmSVmY91lIcNnP2OzYfr2R1DdYd KtKTtulNkf/8bzScqsBqpOeMugGDA2bnIq9SnOAhriIBF7rfi7/K0IEnC4J4ipdEhvL/ dIxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=BWB/r1uMZHjugHdcdJ/l6mX4gfawblsOfx9egY0Loy8=; fh=fHhbvXgCev/wpffLVpfaAi8pPyv7hrTyhVPgsZ7HNrs=; b=VvOxBLt1LD5FEpo8r//VYguhvqDdMMLEKuFS2IOSBMDDa9hhbhl+lMpkgtdABMAWXr A09SOdId2rNGh4jEsmrA+/n87tYvK8KfkKZoYHbVn2jR4jzK5TRHm+Lla1SnIzUTV8Vo L1J4cDcH6+M9UqQgpsQPcULoPfrpMiHBXOg7VG0vLFnKNRtQbM8m30S2iSG5QKVlGg8n e0kpG8UhFlfEuu10XZpvGcd7UUVEfPcHB1WPsyuUXhtmiTzdU2/hax+rpQYkZ3mCoBSN ALAZIYVUCzUCHdbqK0U69vhdGKnY1VpJdB9LNHTzLt7uuIiBtjVIz9gKXhvNz03qkHGg hSBg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OkJkQJbA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-176190-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176190-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f4d2b41a41si4318020b3a.316.2024.05.10.14.05.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 14:05:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176190-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OkJkQJbA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-176190-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176190-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BEBD128745B for ; Fri, 10 May 2024 21:05:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A55D13B7BD; Fri, 10 May 2024 21:04:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OkJkQJbA" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EF60495E5; Fri, 10 May 2024 21:04:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715375094; cv=none; b=TV2SAFwe7TZ3nsO1mOrWrcClrMpYYrPSpY2unZcs3BXPRTJ5XqK3eLjc4L4b4qDpkGIG9WovKswQNVGMa3hsMmKYYvGudLgmHKFyFkL+9ZT89Zz8PQViWWYoF5aSxMOX60Km3FCAcIzOmUazLFSlEHNpiGd3akrkrI3IfKIy8Fs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715375094; c=relaxed/simple; bh=MU37FOLAkBjme+LOgIz/PRnWHSatJ/V8u55IN2abFBs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g+sfnbNUPawo2/+hYZAYkKGSn6pukfxdSBkXpBcyGorownixjwjscuPe8byVzrIfgsJ3rOp+9S8w3crmnu+dsI875JIa7S5GSKTqwFG2JwVYMZwWYStmHp1KDGiTXPg0cbNE5MxomZ6gKGDzYxrB38aomZgljRLn6kk+NlFTo/4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OkJkQJbA; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77FAEC113CC; Fri, 10 May 2024 21:04:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715375093; bh=MU37FOLAkBjme+LOgIz/PRnWHSatJ/V8u55IN2abFBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OkJkQJbA64xgLpBfeHVQG7bNEOmkTisLXSyb/geo8JsMHbjTre2upgQtyYYdm1ofS bB+bOR7iqpV/Q2Z18b8/TgVOgM82zJ2neiwrGXHaIUz9X7zKGfQbtyQmmQ1V0GDK12 Sz1CCWsQe2nKIJXT/FW6wyxnvWjXtcRXnERjslAZFaEqkBJnkXyk4sC6UlfQT/fiAc aRj/MBlQjrc89Lo5BONbQ75xmMbV+pe1+nW9Wgw25LEqC0Sk4C/vRY7slIVVe3F9EO css9242TqMCoP4TvjWNGJLb1Ib8uZ9dTX6O6/s6Qp6zwFnBSx6U9Jfit/sOoCQCFX6 2PnNuCLOqyLKA== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH 1/2] perf annotate: Fix segfault on sample histogram Date: Fri, 10 May 2024 14:04:51 -0700 Message-ID: <20240510210452.2449944-1-namhyung@kernel.org> X-Mailer: git-send-email 2.45.0.118.g7fe29c98d7-goog In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit A symbol can have no samples, then accessing annotated_source->samples hashmap will get a segfault. Fixes: a3f7768bcf48 ("perf annotate: Fix memory leak in annotated_source") Signed-off-by: Namhyung Kim --- tools/perf/util/annotate.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 541988cf6e19..1451caf25e77 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -113,10 +113,11 @@ static __maybe_unused void annotated_source__delete(struct annotated_source *src if (src == NULL) return; - hashmap__for_each_entry(src->samples, cur, bkt) - zfree(&cur->pvalue); - - hashmap__free(src->samples); + if (src->samples) { + hashmap__for_each_entry(src->samples, cur, bkt) + zfree(&cur->pvalue); + hashmap__free(src->samples); + } zfree(&src->histograms); free(src); } -- 2.45.0.118.g7fe29c98d7-goog