Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp428238imp; Thu, 21 Feb 2019 04:23:50 -0800 (PST) X-Google-Smtp-Source: AHgI3IaT4pTu5hudTR/Cm7xWHuo0/l5JZY65Rh/0kKLLnaM/bkbQganDCU1EEUqggQ0YT0p0uyz7 X-Received: by 2002:a63:1625:: with SMTP id w37mr20598205pgl.13.1550751829950; Thu, 21 Feb 2019 04:23:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550751829; cv=none; d=google.com; s=arc-20160816; b=T+swT/aSUDX7SYmkm3Uj03zqgXPW0xBehMfaduRX/xfDuyutlPAIP7MuOaYQzLZLxI zhp9XlRl2dpnY8oklA6PjHfM7LDmFleMWJYRZ9/OEMo1WA/vUKjOlr2qP4y3fC7QEOwi b98xGYk8kfpptMwP1OCABHDnWbaaHKCQdVOfoEwgjy/cpL2sMLCZj6yzsH9l10Gp4EaX 9iOoQZJNypH2slvS0DlLfnSFDczC5zvSuRgJECraYp8PWSwmTacXNTqZWx5TuspvryS9 EMHpn4kUmcRrDcnNnGvAh2O0K2Kk05QRzKxkzvkvwJh4HXrKuq5PyDq4viuFtx6RuIqd PsYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=EaxIBCd4Bumetk6xRQW6JCSRVIQoYNrVu2uL737a+iM=; b=I3guZhbYOkUeoyAwcofuHaaGXocit5C+UyTGj8bj9AnXZVwmVwy45fmgv25g6tEc5D 1v1kSxgKyjt0OfjbpZ8unKXlX14LM4qDRwrAlyza6j8KAmA5f/gInipol4JFaWH0XgkZ wb2knTlIwrwKloQRiZIzdoH9nOCwREtDjfGs2ngML8fvUhq3Nx1nSLq/q+dpu/s4ok2j lrVSrH2s+EtabM+LeMDJwmBMabq7NnDGowKhFzNw5oFFLKtFHM1ruINoVTd+fLHXYIeL bEMD0naaea3+/y8BzdOoMl6tdgVbnuP286+TffPpL1aeIDGT/zLxSeWk/CpFOqZ4n1W0 8J3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q23si10651146pll.74.2019.02.21.04.23.33; Thu, 21 Feb 2019 04:23:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727113AbfBUMXM (ORCPT + 99 others); Thu, 21 Feb 2019 07:23:12 -0500 Received: from mx-rz-1.rrze.uni-erlangen.de ([131.188.11.20]:48598 "EHLO mx-rz-1.rrze.uni-erlangen.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726113AbfBUMXM (ORCPT ); Thu, 21 Feb 2019 07:23:12 -0500 Received: from mx-rz-smart.rrze.uni-erlangen.de (mx-rz-smart.rrze.uni-erlangen.de [IPv6:2001:638:a000:1025::1e]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx-rz-1.rrze.uni-erlangen.de (Postfix) with ESMTPS id 444tsp3631z8tpf; Thu, 21 Feb 2019 13:23:10 +0100 (CET) Authentication-Results: mx-rz-1.rrze.uni-erlangen.de; dkim=none reason="no signature"; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Virus-Scanned: amavisd-new at boeck5.rrze.uni-erlangen.de (RRZE) X-RRZE-Flag: Not-Spam X-RRZE-Submit-IP: 10.21.18.64 Received: from fau.de (faustud-010-021-018-064.pool.uni-erlangen.de [10.21.18.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: U2FsdGVkX19/pJ2rqRpTBMZ1NcUXJ15Nc2/OxnsLyxg=) by smtp-auth.uni-erlangen.de (Postfix) with ESMTPSA id 444tsm2Xsbz8sf8; Thu, 21 Feb 2019 13:23:08 +0100 (CET) From: Jonas Rabenstein To: linux-perf-users@vger.kernel.org Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, Jonas Rabenstein Subject: [PATCH] perf hist: fix memory leak if histogram entry is reused Date: Thu, 21 Feb 2019 13:23:06 +0100 Message-Id: <20190221122306.1511-1-jonas.rabenstein@studium.uni-erlangen.de> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In __hists__add_entry the srcline of the addr_location is duplicated for the hist_entry. If hists__findnew_entry returns an already existing hist_entry the srcline has to be freed again as no further reference to that duplicated srcline would exists anymore. Signed-off-by: Jonas Rabenstein --- tools/perf/util/hist.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 8aad8330e392..25b8dbdbbe87 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -623,6 +623,9 @@ __hists__add_entry(struct hists *hists, .ops = ops, }, *he = hists__findnew_entry(hists, &entry, al, sample_self); + if (he && he->srcline != entry.srcline) + free(entry.srcline); + if (!hists->has_callchains && he && he->callchain_size != 0) hists->has_callchains = true; return he; -- 2.19.2