Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp766314lqo; Fri, 10 May 2024 14:28:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX0VLQnYEQlkxsZ+UDx8spaHecteZgNKkCVop3U5WTZAb9j6LN39ZJpHCxOEpwGZm9WlCS3VtM3wjaas3oqVFTXVAk/jmO/xnbRdy51+Q== X-Google-Smtp-Source: AGHT+IG+8E2LVzKCxri8FBK6JtopojV5jxVKj6iv3xe3z6Nz0YsMitgTJwWCsYh+0jT1ewhkSivx X-Received: by 2002:a19:e043:0:b0:51d:2529:7c4d with SMTP id 2adb3069b0e04-5220f646013mr2175075e87.0.1715376519822; Fri, 10 May 2024 14:28:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715376519; cv=pass; d=google.com; s=arc-20160816; b=owzP86/aeAfIN+eqEWE0WH49vYG6z1CgXYEEykrwwFgOlOPEmkef56YOrM9AY46vOR fW0pOowrUH5yGGpuvuCf1NhLrL7sE1AgtTUpx6tbutzpMtGhCtQ9PfPD9j4xOfET5+x6 Ynrdm4Ij4+tah589I6/UiNJYxBo5229hhuZoDFoYduJg8+zoMPsvSiWAOXmrR82fcSvZ dHwbHiSXE/6+MeU89wDU5Il1FF/Wgmvtqd3PAwgOPWyRpq6Vr2DEFajJjDfieEWMqvbp iFeETouoifU0lN/txCc7deoK6K79uPlAw9dLXAgAhf9cnhjFAPP1RVNqwMjVErALvi9C yAgw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=iMIqC4lMOuMBFP7thYu5aGC3mPK/U3Jb/uL/qezic2U=; fh=G9GhBPDzrvZBDpoq0B25kNosWXA2p9FpD5zAh5rgpL0=; b=ALcUo/b7VkyT2lQwxnLXSa/3wMlc1SaDGxRZM8CfazHBlOBLyz5qG4rQIam3xRjCqO NhXaYCT8PgfBKP8JAcgaR0MQkzV+sJb+XKWVsypyUcwUGeV0GWx0vA8mxX4rDfFTT7xO ZZUyI0D2u7AXSAAT/eIyv2uovxbJjU2WMeQbHMXCF+iEfKcx2Ou00ax+SooWClQfluYD KxjZfs8MSb+Hz+XY9z3NFhnpBsN5G7zIf/akClefqytBCh9UGwWtMGfglfGLsJcwtTS9 aIFsqybkG+iU7VgUED8XXZZ2+sW2CfOR1f+VkX3lObmUcSNpXoC1A5tZLr/MhROQZH8F N2vQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Oc5KTpO+; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-176235-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176235-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5735c8622b0si577592a12.244.2024.05.10.14.28.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 14:28:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176235-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Oc5KTpO+; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-176235-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176235-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3849B1F258E0 for ; Fri, 10 May 2024 21:27:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C914713B5A4; Fri, 10 May 2024 21:27:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Oc5KTpO+" Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (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 987E9495E5 for ; Fri, 10 May 2024 21:27:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715376455; cv=none; b=V/pF4koF/MT0zWgmoAqfFAVGoY7UcAWZ4vw6bouCG3nzKnIKOYCSA7lDLlCR0Ru/rvwvPpYCtoVeMnv7IBFbE5Z8pqIc7uB7/HuLNcNRleoUWvV0vXNP/FmhcXf23IAGI036g29HR8P1EIpbENm2+6C6WArNIBqNCoQvdrXGj/k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715376455; c=relaxed/simple; bh=lvG54KOtblTtm/Gtue2giqL/wNiwZJbkby5y11Swbwk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=pZZaIqzosv94zq6YIRxqZV8vkgWpqbYZ86rWGg8IMCQUS/P9rmpnKso7YcxAmx2JoUKbrx87Dp/pq5GGgC0oAPl6JlgasdnmG/7Wnit+Ya+qTwTOP8so2zzygm/F0tehFO1yE10hKBQMKhuG42Z2d51JgxurKITv6EYVv0J4wao= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Oc5KTpO+; arc=none smtp.client-ip=209.85.160.179 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=google.com Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-43dfe020675so136721cf.0 for ; Fri, 10 May 2024 14:27:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715376452; x=1715981252; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=iMIqC4lMOuMBFP7thYu5aGC3mPK/U3Jb/uL/qezic2U=; b=Oc5KTpO+6mFg4e3qHbMvYCx6B9xrS+E7ZMZa6yHBBDWE65wC67Afhck6rTPCfwhwhX VauIMizFvB546lrSAhlZQa2n83l1R7Yim4FRsv4cDzBI1POhjgGAcHq8Bg055FwPgd+D 8B2jpBy9YYUOPqYJWkHD7EU8bMWkAT7WLyEx0hivOYJ5MKo6zse3ciFRaXp34QVfqg4o FySmBubx7AREjWDQVuYoCJMkvVQm91VYxv1hhwzNfxHiJBHlKpAZLkF32eXSenqRcIVB BvfJRzgBxwH7Gi22XB4hgqf8hCR2poprS9OVkKdskavUdBip/C8R36PDbReBdnmRuZbg ViVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715376452; x=1715981252; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iMIqC4lMOuMBFP7thYu5aGC3mPK/U3Jb/uL/qezic2U=; b=V1UlLYczlPheLpBEqsgb/l2E7vQj4IluFbqUHzPeFxjAKpcxQ+sZd7x/5MUF52Yqd2 q0INBD43WyNcaByObarCMDnYzFh1EieaBtbshxxnEpalqQI43Ajq7HXygEluUPwot7v1 31SG1e1DMln2oh2MKLG95X2Zjz5A4Qohpeijai2ZnD/Twj26mEWU12RjY8wiXiMd+Ybd 3j8OWwiottMGbunzDJstPah5FVCN1WKD46WBys4ydpgQKdkDZEC9H2tmDZof6A9gqx1F RDYapbqTO472k8B1SRol4jKIKxTSy/teDz9e6+GTVMxRzEQJ9YML9pspRQ9L90ylU+nl sxww== X-Forwarded-Encrypted: i=1; AJvYcCXvBh3SUiryoJgY2SGMpsyq6pbr/OoPxiXVuzNVD+Xss7N0umqAhlxPruTrcFuBwfHXruNrL16+cAeCA3xHPyPUtyuMXkVb/Q88s5A5 X-Gm-Message-State: AOJu0YwG/3Zi2cTP1IKjAfeqjKUWfTkH1Q8TQWgkXZ4OWkbOJm/511+F wldclwCGOQTD2+trjS0lo0bt4fwDWMYGtaYk69ayGlFcpuKk0yu9DZKeCFI9qKRT38biooxHi+5 xrdftXW2SfzLFazzceLi7W9t5RxAwlNvDSHbz X-Received: by 2002:a05:622a:4184:b0:43d:e294:3075 with SMTP id d75a77b69052e-43e0a21da9cmr206801cf.7.1715376452341; Fri, 10 May 2024 14:27:32 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240510210452.2449944-1-namhyung@kernel.org> In-Reply-To: <20240510210452.2449944-1-namhyung@kernel.org> From: Ian Rogers Date: Fri, 10 May 2024 14:27:20 -0700 Message-ID: Subject: Re: [PATCH 1/2] perf annotate: Fix segfault on sample histogram To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Kan Liang , Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, May 10, 2024 at 2:04=E2=80=AFPM Namhyung Kim = wrote: > > 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 Reviewed-by: Ian Rogers Thanks, Ian > --- > 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 =3D=3D 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 >