Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1133796lqo; Sat, 11 May 2024 08:43:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWKc0EzIJtMC4JhP1VZbLYoULOQg4N/dGB9s7bu7nXqw+4nkT+ST9zmiOQg5gkVF7I+Ed1rT6XLe7gbgYjvhHaBzuXjVgueUMDILzBClA== X-Google-Smtp-Source: AGHT+IHLfkAP8tVnyiZivZ8ZM7glyXl4zVyiMQP3tGNt2JFuUfHdMvyX+tor3TWk6gWFy6Zff1hk X-Received: by 2002:a05:6214:4586:b0:6a0:b91e:3994 with SMTP id 6a1803df08f44-6a1681e8ca3mr86330196d6.25.1715442197740; Sat, 11 May 2024 08:43:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715442197; cv=pass; d=google.com; s=arc-20160816; b=BCUrusJs7cSSwGDcrNkh3sxexRQ5SCwCCCkN47x30emcadf94GIioW/dC2ZqR1UOrF CoFfFFkERJOiwlfYyA6bNxhPhlsc5ppUCyMKpbbxp/GUXsO2fKuUFTP+h0O91/sB0e97 yGSwFzvpffVELwWMmUNuTKK7NAs65Gx2/Cvik3a2gzXHCzn07mrWX/3rmBuG4eOD2nBY BB+875PQhVFlenrU/0V62b6SUbf1sYTN8mnyb6bnAXYC/GTcrVy0Idpo8VD/w2G0sjPT 0NcactFymncJa37qp8x9IHlJwA2fB0XK7+eplLSTru/hjBGWcbmFuD0RkctAY5Fwcniy KfKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2ChmUttpIkRCglWtPdGWQDvd5vzSBSI9FdRF9U1GFI4=; fh=QPHjG65RNQ4P0Lo50ADGdMc5jntiupTtyaImif19M7E=; b=nOLcwVLi71mSyjzlM26UMbzF4J4fCiQVGzc3C4GB9rMsOF22jdh2WyIzNej/dU1jtG AdzExjx6yUP+HkINf2iayfGwP+EbXSynbdxAamxjKz2J1m0KG+vFSkmFAADBK8ec34xN eHsex6+9pFLXGaCfuZ0l4IgRc2BSz1XbQT0a3yIImGOkAFevBoxaGP1higQbmOPkPZht eq/CWsH96zb19nDPzHwsxl2Jq+EscfQ45KVTfPsUTLA/os6F1xHJ7O51aeR5bfkUT3Jq YgeeebpOy0k/L4jun/R+wqj2k+qCIn1Uk6bRZq4OhVXdoI+utRQSn3TP5R6UxdBOi0t+ MTHg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iTQfWTS1; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-176616-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176616-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6a15f1d6dc4si60158906d6.56.2024.05.11.08.43.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 08:43:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176616-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iTQfWTS1; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-176616-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176616-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 775F61C20B09 for ; Sat, 11 May 2024 15:43:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 936CC56759; Sat, 11 May 2024 15:43:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iTQfWTS1" 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 B424E38DD3; Sat, 11 May 2024 15:43:08 +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=1715442188; cv=none; b=P8WBgg+ljqDwHmbhPpC7cOHkizefJf6qn7TJtNAoEQZvtPrXnMfs8sg/sG3zmHw9UXWyhl/Ae1eo8hyn2DxYF1xWfD32eAqhekone6kaL5tnJ36MVSOi46wM78tB5DTqO4v7EwnZEDqz1whu0nknoJfQRCzk4xrQwqYy6qngLEc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715442188; c=relaxed/simple; bh=XXaqHCJAzABGwZ2wMv/Kt7MKG+X9S9a1FPy02FlWTAY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XbQFjgYd/Ym0rD5vl5ygpNrmbiUruHFWWC5AfVhU1YbE3kh3zO2bQD1/WgX5TTu71RPneL9H1xh1Jtc7q/58/HeuBC25UGjP2xNdghHx8t2mMfyC5p5MiyynhK4+YCZfMyH16Sb/5MJy/ncRCZ9Thu7Pz90FD2GLSZhti5krgOM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iTQfWTS1; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E861BC2BBFC; Sat, 11 May 2024 15:43:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715442188; bh=XXaqHCJAzABGwZ2wMv/Kt7MKG+X9S9a1FPy02FlWTAY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iTQfWTS1WL8RtJn8ViiE9QQ33xfj0QEUahYMpeiAdrn5gN7J6oTZ+1nwHs9jbKXTK Q5Pc0BOLu/E7ybOfETp1byuTaoIbVKEFcHzLKSp0+52U+rPem/VxWy4UAy6/3PlMud TtpDlKrpe7TdxGaJFabq9G37EuC4wvgrJScAU75hoQr1uAfydZqH0Ee/NvR2JU2/i3 JUPfRDyM7ZQGj7ZONiUBZgXK9gJwLzVvaw1F73BAN1e8Whq1tV4IxFKHKz3+2Q5tf0 cTUf0RwQEvBd/KxmRvAP66rFHmDJqpPj+UUOvnFXyvdD87xsRH+vtyP7jqF0d2y44G lvPFQ9PkgvBCw== Date: Sat, 11 May 2024 12:43:04 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Namhyung Kim , Kan Liang , Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: Re: [PATCH 2/2] perf annotate-data: Ensure the number of type histograms Message-ID: References: <20240510210452.2449944-1-namhyung@kernel.org> <20240510210452.2449944-2-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, May 10, 2024 at 02:27:36PM -0700, Ian Rogers wrote: > On Fri, May 10, 2024 at 2:04 PM Namhyung Kim wrote: > > > > Arnaldo reported that there is a case where nr_histograms and histograms > > don't agree each other. It ended up in a segfault trying to access NULL > > histograms array. Let's make sure to update the nr_histograms when the > > histograms array is changed. > > > > Reported-by: Arnaldo Carvalho de Melo > > Signed-off-by: Namhyung Kim > > Reviewed-by: Ian Rogers Thanks, applied to perf-tools-next, - Arnaldo > Thanks, > Ian > > > --- > > tools/perf/util/annotate-data.c | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-data.c > > index 57e7d4b3550b..965da6c0b542 100644 > > --- a/tools/perf/util/annotate-data.c > > +++ b/tools/perf/util/annotate-data.c > > @@ -1800,7 +1800,6 @@ static int alloc_data_type_histograms(struct annotated_data_type *adt, int nr_en > > sz += sizeof(struct type_hist_entry) * adt->self.size; > > > > /* Allocate a table of pointers for each event */ > > - adt->nr_histograms = nr_entries; > > adt->histograms = calloc(nr_entries, sizeof(*adt->histograms)); > > if (adt->histograms == NULL) > > return -ENOMEM; > > @@ -1814,6 +1813,8 @@ static int alloc_data_type_histograms(struct annotated_data_type *adt, int nr_en > > if (adt->histograms[i] == NULL) > > goto err; > > } > > + > > + adt->nr_histograms = nr_entries; > > return 0; > > > > err: > > @@ -1827,7 +1828,9 @@ static void delete_data_type_histograms(struct annotated_data_type *adt) > > { > > for (int i = 0; i < adt->nr_histograms; i++) > > zfree(&(adt->histograms[i])); > > + > > zfree(&adt->histograms); > > + adt->nr_histograms = 0; > > } > > > > void annotated_data_type__tree_delete(struct rb_root *root) > > -- > > 2.45.0.118.g7fe29c98d7-goog > >